Last active
March 27, 2016 09:23
-
-
Save namelos/95e14f8439d930d90ad4 to your computer and use it in GitHub Desktop.
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 { Observable, Subject } from 'rx' | |
| const { timer, fromEvent } = Observable | |
| /* --- logic --- */ | |
| const main = DOM => | |
| DOM.startWith(null) | |
| .flatMapLatest( | |
| () => timer(0, 100).map( | |
| i => `seconds elapsed ${i}`)) | |
| /* --- effects --- */ | |
| const DOM = text$ => { | |
| text$.subscribe(text => | |
| document.querySelector('#app').textContent = text) | |
| return fromEvent(document, 'click') | |
| } | |
| /* --- binding --- */ | |
| const run = (main, driver) => { | |
| const proxy = new Subject() | |
| driver(main(proxy)) | |
| .subscribe(proxy::proxy.onNext) | |
| } | |
| /* --- run --- */ | |
| run(main, DOM) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment