Skip to content

Instantly share code, notes, and snippets.

@colinf
Last active July 13, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save colinf/aa4ed68670149bc2e90d to your computer and use it in GitHub Desktop.
Save colinf/aa4ed68670149bc2e90d to your computer and use it in GitHub Desktop.
Base Flux Store class in ES6 ( See http://bit.ly/29RY6gq )
import EventEmitter from 'events';
var CHANGE_EVENT = 'change';
class Store extends EventEmitter {
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;
@andrewmclagan
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment