xs-combine-obj

1.1.1 • Public • Published

combineObj for xstream

npm install xs-combine-obj

A port of combineLatestObj to xstream.

Usage

Given these observables:

const a$ = xs.periodic(50).take(3);
const b$ = xs.of('Boston');
const c$ = xs.of('Colorado');

Make an observable which is the combination of them, bundled as an object.

import combineObj from 'xs-combine-obj';
 
const state$ = combineObj({a$, b$, c$});
// or const state$ = combineObj({a: a$, b: b$, c: c$});
 
state$.addListener({
  next: x => console.dir(x),
  error: () => {},
  complete: () => {}
});
// {a: 0, b: 'Boston', c: 'Colorado'}
// {a: 1, b: 'Boston', c: 'Colorado'}
// {a: 2, b: 'Boston', c: 'Colorado'}

It takes Cycle.js' hungarian notation $ into consideration, returning an object whose keys don't have the $.

The above is more convenient than writing:

var stateAlt$ = xs.combine(a$, b$, c$).map(([a, b, c]) => ({a, b, c}));

Credit: Code and README example pulled from combineLatestObj

Readme

Keywords

none

Package Sidebar

Install

npm i xs-combine-obj

Weekly Downloads

5

Version

1.1.1

License

MIT

Last publish

Collaborators

  • ntilwalli