Last active
February 7, 2016 22:07
-
-
Save kahlil/52c5069caeaa06ba23b9 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 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