Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use Stanga (https://github.com/milankinen/stanga) as a wrapper, not as a driver
// Generic helper function that takes a main() (the top-level component)
// and wraps it with Stanga logic
function wrapWithStanga(main, initialState) {
return function (sources) {
const modProxy$ = new Subject();
const modelSource = Model(initialState)(modProxy$);
sources.model = modelSource;
const sinks = main(sources);
sinks.model.subscribe(modProxy$);
return sinks;
}
}
// Usage example
function main(sources) {
// return sinks...
}
const initialState = {name: 'Sara', job: 'Designer'}
Cycle.run(wrapWithStanga(main, initialState), {
DOM: makeDOMDriver('#app')
});
// See a full example at http://www.webpackbin.com/EkzrrSRmZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.