Skip to content

Instantly share code, notes, and snippets.

@sajithdilshan
Created January 27, 2018 19:58
Show Gist options
  • Save sajithdilshan/6628bc19419021432a97cf0d9450ba17 to your computer and use it in GitHub Desktop.
Save sajithdilshan/6628bc19419021432a97cf0d9450ba17 to your computer and use it in GitHub Desktop.
import dispatcher from "../Dispatcher";
import {EventEmitter} from "events";
import * as ColorAppActions from "../actions/ColorAppActions";
class ColorAppStore extends EventEmitter {
constructor() {
super();
this.activeColor = "lightgrey";
}
handleActions(action) {
switch (action.type) {
case ColorAppActions.COLOR_APP_ACTIONS.CHANGE_COLOR: {
this.activeColor = action.value;
this.emit("storeUpdated");
break;
}
default: {
}
}
}
getActiveColor() {
return this.activeColor;
}
}
const colorAppStore = new ColorAppStore();
dispatcher.register(colorAppStore.handleActions.bind(colorAppStore));
export default colorAppStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment