Skip to content

Instantly share code, notes, and snippets.

@back2dos
Created February 9, 2017 17:08
Show Gist options
  • Save back2dos/17e165019c23820063155c402ed293be to your computer and use it in GitHub Desktop.
Save back2dos/17e165019c23820063155c402ed293be to your computer and use it in GitHub Desktop.
class Container<Action, State> {
var state:tink.state.State<State>;
var reducer:State->Action->State;
public function new(initial, reducer) {
this.state = new State(initial);
this.reducer = reducer;
}
public function dispatch(action:Action)
state.set(reducer(state.value, action));
public function bind(?options, cb)
return state.observe().bind(cb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment