Last active
April 25, 2016 08:13
-
-
Save takashi/a7838bb3aaf301a36921 to your computer and use it in GitHub Desktop.
cycle.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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