Name: cyclejs-utils
Owner: Cycle.js Community
Description: A few helper functions for dealing with sinks
Created: 2017-01-22 14:04:57.0
Updated: 2017-11-15 09:55:33.0
Pushed: 2017-11-14 12:18:49.0
Homepage: null
Size: 189
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A few helper functions for dealing with sinks
git repository: https://github.com/cyclejs-community/cyclejs-util
npm package: https://www.npmjs.com/package/cyclejs-utils
typedoc documentation: https://cyclejs-community.github.io/cyclejs-util/index.html
The most useful functions are mergeSinks
and extractSinks
.
rt { ChildComponent } from 'XXX'
rt { Sinks, mergeSinks$, filterProp, extractSinks } from 'cyclejs-utils'
t drivers = { /* ... */ };
t driverNames = Object.keys(drivers);
tion main(sources)
const children$ : Stream<Sinks[]> = sources.state
.map(s => s.childState.map(c => ChildComponent(sources)));
//Create a combined DOM of the children
const vdom$ : Stream<VNode> = children$
.map(arr => xs.combine(...arr.map(s => s.DOM)))
.flatten()
.map(div); //Just display the children in a div
//Merge all children Sinks automaticly
const child$ : Stream<Sinks> = children$.map(arr => mergeSinks(...arr));
const childSink : Sinks = filterProp(
extractSinks(child$, driverNames), //Transform a Stream of Sinks to a normal Sinks object
'DOM'
); //give me a driver object without the DOM property
return Object.assign({}, childSink, { DOM: vdom$ });