Last active
September 20, 2016 04:25
-
-
Save TheSeamau5/89b50e2c23e956288595253423137955 to your computer and use it in GitHub Desktop.
Runner Generator (useful to generate different runners depending on the platform)
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
// makeRunner : (renderer : ReactComponent -> ()) | |
// -> (update : s -> a -> s, render : s -> Dispatcher a -> ReactComponent, observable : Observable a) | |
// -> () | |
export const makeRunner = (renderer) => (update, render, observable) => { | |
const store = createStore(update); | |
const renderApp = () => renderer(render(store.getState(), store.dispatch)); | |
renderApp(); | |
if (observable) { | |
observable.subscribe(store.dispatch); | |
} | |
store.subscribe(renderApp); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment