Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Last active September 20, 2016 04:25
Show Gist options
  • Save TheSeamau5/89b50e2c23e956288595253423137955 to your computer and use it in GitHub Desktop.
Save TheSeamau5/89b50e2c23e956288595253423137955 to your computer and use it in GitHub Desktop.
Runner Generator (useful to generate different runners depending on the platform)
// 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