window.onload = () => run(main, drivers());
const value$ = DOM.select('.name').events('input') .map(get('target.value')) .startWith('') const submitted$ = DOM.select('form').events('submit') .do(event => event.preventDefault()) .map(() => true) .startWith(false) .take(2) const vtree$ = value$.map((value) => form([ label('Name:'), input('.name', {props: {type: 'text', value}}), input({props: {type: 'submit'}}), ]) ) return { DOM: vtree$, value: value$, submitted: submitted$, } } const drivers = { DOM: makeDOMDriver('#app-container'), horizon: makeHorizonDriver(), } run(main, drivers)
import { merge } from 'ramda'; import { Sandbox } from './components/sandbox'; import { appModel } from './app-model'; import { appView } from './app-view'; function main(sources) { const route$ = appModel(); const sandbox = Sandbox(sources); const sinks = { DOM: appView(sandbox.DOM), store: Observable.merge(route$, sandbox.data) .scan(merge, {}), }; return sinks; } // Note: drivers use xstream function dummyDriver(initialValue) { return (value$) => value$.remember().startWith(initialValue); } run(main, { DOM: makeDOMDriver('#app-container'), store: dummyDriver({}), });