Skip to content

Instantly share code, notes, and snippets.

@DavidSouther
Last active August 29, 2015 14:14
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 DavidSouther/7e5119869cbae9d36901 to your computer and use it in GitHub Desktop.
Save DavidSouther/7e5119869cbae9d36901 to your computer and use it in GitHub Desktop.
Song Flux 2 - Store Registers
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