Created
January 27, 2018 19:58
-
-
Save sajithdilshan/6628bc19419021432a97cf0d9450ba17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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