Skip to content

Instantly share code, notes, and snippets.

@glortho
Last active October 15, 2015 14:59
Show Gist options
  • Save glortho/55d87023e1e7cda5a199 to your computer and use it in GitHub Desktop.
Save glortho/55d87023e1e7cda5a199 to your computer and use it in GitHub Desktop.
Use decorators for dispatching actions in Flux - https://gist.github.com/jedverity/b3e3a06761daefeca110
// Note: examples below use https://gist.github.com/jedverity/b3e3a06761daefeca110
class MyActionCreator {
@dispatch('SOME-ACTION')
updateStore(data) {
return data; // this will be dispatched with 'SOME-ACTION' as the actionType
}
@dispatch('SOME-ASYNC-ACTION')
postData(data) {
return MyApi.post('/url', data );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment