Last active
September 3, 2016 05:41
-
-
Save MelleB/b9094c843bcc66bc65c31f66a7761bec to your computer and use it in GitHub Desktop.
This file contains 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 { run } from '@cycle/xstream-run'; | |
import xs, { Stream } from 'xstream'; | |
import { DOMSource } from "@cycle/dom/xstream-typings"; | |
import { makeDOMDriver, div, input, p, VNode } from '@cycle/dom'; | |
import Sidebar from './components/sidebar'; | |
export class UIState { | |
public selectedTool: string; | |
} | |
export interface IUIStateSource { | |
UIState$: Stream<UIState> | |
} | |
export interface IDOMSource { | |
DOM: DOMSource; | |
} | |
export interface IUIStateSink { | |
UIState$: Stream<UIState> | |
} | |
export interface IDOMSink { | |
DOM: Stream<VNode>; | |
} | |
function main(sources: IDOMSource & IUIStateSource): IDOMSink & IUIStateSink { | |
let sidebar = Sidebar(sources); | |
const vtree$ = xs.combine(sidebar.DOM /* ,other DOMSources here */) | |
.map(cn => div('#app', cn)); | |
return { | |
DOM: vtree$, | |
UIState$: sidebar.UIState$ | |
}; | |
} | |
const drivers: { [name: string]: Function } = { | |
DOM: makeDOMDriver(document.body), | |
UIState$: () => xs.of({ selectedTool: 'task' } as UIState) | |
}; | |
run(main, drivers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment