Skip to content

Instantly share code, notes, and snippets.

@takashi
Last active April 25, 2016 08:13
Show Gist options
  • Select an option

  • Save takashi/a7838bb3aaf301a36921 to your computer and use it in GitHub Desktop.

Select an option

Save takashi/a7838bb3aaf301a36921 to your computer and use it in GitHub Desktop.
cycle.js
import Cycle, {Rx} from '@cycle/core'
import {h, makeDOMDriver} from '@cycle/dom';
const intent = () => {};
const model = (actionMap) => Rx.Observable.just([]);
const view = (stateStream) => {
return stateStream.map((state) => {
return h('div', [
'test'
]);
});
};
/**
* _____________MVI_____________
* | |
* DOM → | intent → model → view | → DOM
* |___________________________|
*
*/
const main = ({DOM}) => {
const actionMap = intent(DOM);
const stateStream = model(actionMap);
const treeStream = view(stateStream);
return {
DOM: treeStream
}
};
Cycle.run(main, {
DOM: makeDOMDriver('#main-container')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment