Giter VIP home page Giter VIP logo

RxJS Extensions

codeql Tests Status Coverage Status npm (scoped) Snyk Vulnerabilities for npm scoped package @rxjsx/rxjsx Maintainability

RxJS operators to deal with arrays, tuples, and dragging the original values along while adding more values to the pipeline.

🛠️ Install

npm install --save @rxjsx/rxjsx rxjs

🧑‍💻 Demo

import { of } from 'rxjs';
import { flatListMap } from '@rxjsx/rxjsx';

of([1, 2, 3], [4], [5, 6])
    .pipe(flatListMap(x => of(x, 10+x)))
    .subscribe(console.log);

You can experiment with the above code by forking this ReplIt repo or through this Medium article.

📖 Examples

// instead of this
of([1, 2, 3]).pipe(map(l => l.map(e => e * 2))

// you can do this
of([1, 2, 3]).pipe(listMap(e => e * 2)) // [2, 4, 6]
// instead of this
let device;
deviceService.getDevice(id)
  .pipe(tap(_device => device = _device))
  .pipe(flatMap(_device => userService.getUser(device.owner)))
  .pipe(map(_user => userService.unassignDevice(_user, _device)))

// you can do this
deviceService.getDevice(id)
  .pipe(flatZipMap(device => userService.getUser(device.owner)))
  .pipe(map(([device, user]) => userService.unassignDevice(user, device)))

📓 Manual

The available operators so far are the following:

Operator Description
flatMap / mergeMap RxJS's mergeMap alias
zipMap To zip the transformed value with the original value
flatZipMap / mergeZipMap Similar to zipMap, but to be used when a transformation returns an observable
projectToFormer To project an observable of pairs, to get the first coordinate
projectToLatter To project an observable of pairs, to get the second coordinate
projectTo To project an observable of tuples
mapFormer To transform the first coordinate of an observable of pairs
mapLatter To transform the second coordinate of an observable of pairs
flatMapFormer / mergeMapFormer Similar to mapFormer, but to work on stream-returning transformations
flatMapLatter / mergeMapLatter Similar to mapLatter, but to work on stream-returning transformations
listMap To transform an observable of list, with a mapping on the list elements
flatListMap / mergeListMap To transform an observable of list, with a stream-returning member transformation
listFlatMap To transform an observable of list, with a list-returning member transformation
flatListFlatMap / mergeListFlatMap To transform an observable of list, with a list-observable-returning transformation

💪 Thanks to all Contributors

List of Contributors

📚 Related Literature

⌨️ Contributing

🙏 Support

This project needs your support. Don't forget to leave a ⭐ behind.

RxJSx's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.