-
-
Save andrewmclagan/33f3491758e24a30f911 to your computer and use it in GitHub Desktop.
Base Flux Store class in ES6 ( See http://cl.ly/0J3j3D1k0742 )
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 EventEmitter from 'events'; | |
class Store extends EventEmitter { | |
static CHANGE_EVENT = 'change'; | |
constructor() { | |
super(); | |
} | |
emitChange() { | |
this.emit(CHANGE_EVENT); | |
} | |
addChangeListener(callback) { | |
this.on(CHANGE_EVENT, callback); | |
} | |
removeChangeListener(callback) { | |
this.removeListener(CHANGE_EVENT, callback); | |
} | |
} | |
Store.dispatchToken = null; | |
export default Store; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment