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/06f1e07321ced56c08e4 to your computer and use it in GitHub Desktop.
Save JLarky/06f1e07321ced56c08e4 to your computer and use it in GitHub Desktop.
const onDispatch = (action: Event) => {
switch(action.type) {
case GreetingActionTypes.ADD_GREETING:
let payload1 = (<AddGreetingEvent> action).payload;
this._state.newGreeting = '';
this._state.greetings = this._state.greetings.concat(payload1);
this.emitChange();
break;
case GreetingActionTypes.REMOVE_GREETING:
let payload2 = (<RemoveGreeting> action).payload;
this._state.greetings = this._state.greetings.filter(g => g !== payload2);
this.emitChange();
break;
case GreetingActionTypes.NEW_GREETING_CHANGED:
let payload3 = (<NewGreetingChanged> action).payload;
this._state.newGreeting = payload3;
this.emitChange();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment