-
Notifications
You must be signed in to change notification settings - Fork 0
Stores
lubelski edited this page Nov 16, 2014
·
1 revision
Stores are the heart and sole of a flux app.
App.createStore(name, storeOptions)
Kitchen = pipeline.createApp()
Kitchen.createStore('tortillas',
API:
getTortillaCount: (brand) -> @get(brand)
getTotalTortillaCount: -> _.reduce(@getData(), (sum, count) -> sum = sum + count)
actions:
addToritilla: (brand, count) ->
current = @get(brand)
@update(brand, current + count)
Kitchen.createStore('pantry',
actions:
addToritilla: ->
{brand, count} = @action
@action
is always available in the context where a stores callback is evaluated. This, combined with the actions packager function, forces the variable and property names to be the same across multiple stores' callbacks. This makes it easier to move between different parts of the codebase.