-
Notifications
You must be signed in to change notification settings - Fork 0
Actions
lubelski edited this page Nov 16, 2014
·
1 revision
App.createAction()
creates a function packages its arguments and passes that data into the system to be processed by the stores.
The packager function should return a single object.
Syntax:
App.createAction(actionName, packagerFunction)
Example:
PipeCleaner = pipeline.createApp()
PipeCleaner.createAction('newFoo', (foo, bar) -> foo:foo, bar:bar)
PipeCleaner.createAction('deleteFoo', (fooId) -> fooId:fooId)
It may be useful to put syntactic or type checks into the packager function. If the packager function returns false, the action will not be passed to the stores.
PipeCleaner.createAction('newFoo', (foo, bar) ->
if typeof bar isnt string
console.log('invalid bar: ', bar, '. Bar must be a string')
return false
foo:foo, bar:bar
For convenience, the App.createActions()
method allows for the creation of multiple actions at one and allows for name-spacing actions.
App.createActions(actionsHash)
PipeCleaner.createACtions
newFoo: (foo, bar) -> foo:foo, bar:bar
deleteFoo: (fooId) -> fooId: fooId
baz:
newBaz: (baz) -> baz:baz
deleteBaz: (bazId) -> bazId:bazId