flyd-cacheUntil editorconfig eslint travis-ci npm

Cache a stream's output until triggered by another stream.

3 years after

flyd-cacheUntil

Travis npm David David

Cache a stream's output until triggered by another stream. Returns an Immutable.List of cached values.

Signature

Stream<E> -> Stream -> Stream<List<E>>

Usage

import flyd from 'flyd';
import cache from 'flyd-cacheuntil';
/* or */
import cacheUntil from 'flyd-cacheuntil';

const stream = flyd.stream();
const trigger = flyd.stream();
const cachedStream = cache(stream).until(trigger);
/* or */
const cachedStream = cacheUntil(trigger, stream);

flyd.on(x => {
  console.log('Output:', x.toJS());
}, cachedStream);

stream(1)(2)(3)(4)(5);
trigger(true);

stream('a')('b')('c')('d')('e');
trigger(true);

// Output: List [ 1, 2, 3, 4, 5 ]
// Output: List [ "a", "b", "c", "d", "e" ]

Top Contributors

ThomWright

Releases

-   v0.4.0 zip tar
-   v0.3.0 zip tar
-   v0.2.1 zip tar
-   v0.2.0 zip tar
-   v0.1.1 zip tar
-   v0.1.0 zip tar