jam-cloud/web/app/assets/javascripts/react-components/stores/JamTrackStore.js.coffee

34 lines
686 B
CoffeeScript

$ = jQuery
context = window
logger = context.JK.logger
rest = context.JK.Rest()
EVENTS = context.JK.EVENTS
JamTrackActions = @JamTrackActions
@JamTrackStore = Reflux.createStore(
{
listenables: JamTrackActions
jamTrack: null
init: ->
# Register with the app store to get @app
this.listenTo(context.AppStore, this.onAppInit)
onAppInit: (app) ->
@app = app
onOpen: (jamTrack) ->
if @jamTrack?
@app.notify({text: 'Unable to open JamTrack because another one is already open.'})
return
@jamTrack = jamTrack
this.trigger(@jamTrack)
onClose: () ->
@jamTrack = null
this.trigger(@jamTrack)
}
)