rx-combine-latest-start-undefined

1.0.2 • Public • Published

combineLatestStartUndefined for RxJS

npm install rx-combine-latest-start-undefined

Usage

This function has the exact same usage as Rx.Observable.combineLatest, including the ability to use a resultSelector function

The example below is a variation on the example at staltz/combineLatestObj.

Given these observables:

const a$ = Rx.Observable.interval(50).share();
const b$ = Rx.Observable.just('Boston').delay(125).share();
const c$ = Rx.Observable.just('Colorado').delay(200).share();

Makes an observable which does not wait until all input observables have had an onNext event before emitting. This version emits immediately with undefined placeholder values until the next emission from the observable. This can be useful for situations where you want to see data as soon as it comes in from any of the observables, and are willing to manage the undefined inputs in your app code.

import combineLatestStartUndefined from 'rx-combine-latest-start-undefined';

const state$ = combineLatestStartUndefined(a$, b$, c$).take(6);
// or const state$ = combineLatestStartUndefined({[a$, b$, c$]).take(6);

state$.subscribe(x => console.dir(x));
// Time 0:   [undefined, undefined, undefined]
// Time 50:  [0, undefined, undefined]
// Time 100: [1, undefined, undefined]
// Time 125: [1, 'Boston', undefined]
// Time 150: [2, 'Boston', undefined]
// Time 200: [2, 'Boston', 'Colorado']

Package Sidebar

Install

npm i rx-combine-latest-start-undefined

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • ntilwalli