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

27 lines
602 B
CoffeeScript

$ = jQuery
context = window
logger = context.JK.logger
@InstrumentStore = Reflux.createStore(
{
listenables: @InstrumentActions
instruments: []
instrumentLookup: {}
init: ->
# Register with the app store to get @app
this.listenTo(context.AppStore, this.onAppInit)
onAppInit: (@app) ->
rest.getInstruments().done (instruments) =>
@instruments = instruments
for instrument in instruments
@instrumentLookup[instrument.id] = instrument.description
@trigger(@instruments)
display: (id) ->
@instrumentLookup[id]
}
)