Last active
August 29, 2015 14:14
-
-
Save DavidSouther/7e5119869cbae9d36901 to your computer and use it in GitHub Desktop.
Song Flux 2 - Store Registers
This file contains hidden or 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
PlayerFactory = function(Actions, song) { | |
function PlayerStore() { | |
global.EventEmitter.call(this); | |
this.dispatcher = song.getDispatcher('trkstr'); | |
this.Events = PlayerStore.Events; | |
this.currentTrack = { title: "Nothing Playing..." }; | |
this.doPlay = this.dispatcher.register(Actions.Play, this.play.bind(this)); | |
} | |
PlayerStore.prototype = Object.create(EventEmitter.prototype); | |
PlayerStore.prototype.play = function(playAction) { | |
this.currentTrack = playAction.track; | |
this.emit(PlayerStore.Events.TrackChanged); | |
}; | |
PlayerStore.Events = { | |
TrackChanged: 'TrackChanged' | |
}; | |
return new PlayerStore(); | |
}; | |
PlayerFactory.$inject = [ 'TrkstrActions', 'songFactory' ]; | |
angular.module('trkstr.stores.player', [ | |
'trkstr.actions', 'songFlux' | |
]).factory('PlayerStore', PlayerFactory); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment