Skip to content

ThomWright/flyd-cacheUntil

Repository files navigation

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" ]

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published