rxjs-multi-scan

multiScan operator for RxJS - A combination operator that combines multiple sources of scan operations.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
rxjs-multi-scan
1401.0.24 years ago4 years agoMinified + gzip package size for rxjs-multi-scan in KB

Readme

multiScan operator for RxJS

rxjs-multi-scan

A combination operator that combines multiple sources of scan operations.

Installation

Install using NPM CLI
npm install --save rxjs-multi-scan

or using Yarn CLI
yarn add rxjs-multi-scan

Use cases

Create a reactive state container that reacts to multiple observables with a simple, easy-to-read syntax. Each source is combined with a reducer function to reduce the current state and the emitted value to a new state.

Usage

import { Observable, Subject } from 'rxjs';
import { multiScan } from 'rxjs-multi-scan';

const initialCount: number = 0;
const add: Subject<number> = new Subject();
const subtract: Subject<number> = new Subject();
const count: Observable<number> = multiScan(
  add, (count, addend) => count + addend,
  subtract, (count, subtrahend) => count - subtrahend,
  initialCount);