Skip to content

Instantly share code, notes, and snippets.

@JLarky
Created March 1, 2016 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JLarky/fb316a3f5c74887a2e20 to your computer and use it in GitHub Desktop.
Save JLarky/fb316a3f5c74887a2e20 to your computer and use it in GitHub Desktop.
const onDispatch = (action: Event) => {
if (action instanceof AddGreetingEvent) {
const {payload} = action;
this._state.newGreeting = '';
this._state.greetings = this._state.greetings.concat(payload);
this.emitChange();
} else if (action instanceof RemoveGreeting) {
const {payload} = action;
this._state.greetings = this._state.greetings.filter(g => g !== payload);
this.emitChange();
} else if (action instanceof NewGreetingChanged) {
const {payload} = action;
this._state.newGreeting = payload;
this.emitChange();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment