1.0.2 • Published 6 years ago

rxjs-multi-scan v1.0.2

Weekly downloads
75
License
MIT
Repository
github
Last release
6 years ago

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);