Skip to content

Instantly share code, notes, and snippets.

@kahlil
Last active February 7, 2016 22: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 kahlil/52c5069caeaa06ba23b9 to your computer and use it in GitHub Desktop.
Save kahlil/52c5069caeaa06ba23b9 to your computer and use it in GitHub Desktop.
import ACTION_CONSTANTS from '../../constant/action-constants';
import Rx from 'rx';
class SomeStore {
constructor(dispatcher) {
'ngInject';
this.dispatcher = dispatcher;
this.someState = false;
this.subject = new Rx.ReplaySubject(1);
this.registerActionHandlers();
}
registerActionHandlers() {
this.dispatcher
.filter((action) => action === ACTION_CONSTANTS.SOME_ACTION)
.subscribe(() => this.changeSomeState());
}
changeSomeState() {
this.someState = !this.someState;
this.emitChange();
}
emitChange() {
this.subject.onNext(this.someState);
}
}
export default SomeStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment