In Flux
, what is the point of using actions
, instead of just letting the component
publish directly to the dispatcher
? What is it that I can't do without actions
?
React Flux: what's the point of actions?
Asked Answered
There's nothing you couldn't do without actions, however, it's simply a pattern they've established to encourage a particular style of programming. facebook.github.io/flux/docs/overview.html Some might suggest they're more testable, but again, there are other ways of doing that. –
Portulaca
They form the API of the application. Collecting them in one place makes it easy to reuse them in different parts of the application. –
Liatris
The action creators decouple the component from the dispatcher. You could replace the dispatcher and related pieces with something else and the components would not need to change.
© 2022 - 2024 — McMap. All rights reserved.