javascript - In "Reflux", what purpose do actions serve? -
i'm familiarising myself both flux architecture, , reflux - simpler version, without dispatcher - use reactjs.
in full flux, sounds actions have (or @ least, can made have) definite , non-trivial purpose: can used update external services (eg. save data server via api), described in question: should flux stores, or actions (or both) touch external services?
however, in reflux, actions dumb message parsers. question is, purpose serve? why have them @ all? bad things happen if views/components called methods on store directly?
i'm convert little app flux reflux, , looks i'll moving logic in actions on store. seems me actions in reflux nothing other act useless middleman between component , store. missing?
besides ability listen action in number of stores pointed out in op comments:
reflux actions can touch apis , such, placing in preemit action hook example. typically you'd create async action, add async stuff in preemit hook, , call "completed" or "failed" sub-actions when async work done (or has failed). can sync work in preemit hook of course. logging comes mind.
it's possible listen action in store , perform async work in store, call .completed or .failed there, think consensus has formed stores shouldn't work, stores should react changing data, not perform business logic.
async actions work promises. of course implement stores well, i'd argue that's lot of responsibilities data store.
Comments
Post a Comment