A collection of commonly used utilities for creating / working with reactive streams or iterables. Included utilities follow the callbag specification.
npm i callbag-common
👉 If you do not know what reactive streams or callbags are, read this post first.
- of: Convert static value(s) to a callbag.
- fromEvent: Listen to DOM event.
- fromPromise: Converts a promise to a callbag.
- interval: Emits an increasing number at given intervals.
- map: Transforms incoming values.
- filter: Filters incoming values.
- take: Take a maximum number of values from source.
- startWith: Start with given values.
- scan: Combine consecutive values from source.
- flatten: Flattens higher-order callbags.
- debounce: Debounces incoming values.
- expr: Create expressions from other callbags.
- merge: Merges given callbags, emitting when each one emits.
- combine: Combines given callbags, emits arrays of latest values of each.
- pipe: Pipes sources to operators to sinks.
- subscribe: Subscribes to given callbag.
- tap: Taps into given callbag (without subscribing).
- source: Converts non-callbags to callbag sources.
callbag-basics is maintained relatively slowly, specifically due to the fragmantation
of both utilities included and export targets (for example tap()
is missing since it lacks types, or examples
on the README are not working due to environment differences).
In callbag-commons, on the other hand:
- Callbags are picked based on active usage in real-life projects.
- Specifically targeting TypeScript / ES6 (no pre-bundled version as that means no tree-shaking).
- External libraries used, whenever possible.
- Internal alternatives used, whenever external library not possible.
So ideally, in the long run, this should be not much different from callbag-basics. It will basically be eventually decentralized and always available (everything working in target environments properly).