Make events.action More Functional
See original GitHub issueToday the following default events may return a value to be used by the app in some way: events.load
, events.resolve
, events.update
, and events.render
. The astute among you may have already noticed that events.action
was missing from that list, which is because today its return value is completely thrown away and so it can only be used for the purpose of side effects.
So what might a return value from events.action
be used for? Well, the name
of the action has already picked which action function to call, so it doesn’t really make sense to allow returning a different name. However, since data
was what was passed to the original action function, it might make sense for events.action
to allow returning a different set of data to act as a sort of middleware for action data. A bonus feature would be allowing the return of false
to completely cancel an action (perhaps due to some value in state
that makes the action invalid), but I’m not sure if false
would ever legitimately be used as the data value for an action.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (14 by maintainers)
Technically
events.resolve
can already be used to cancel everything an action does except for calling other actions as side effects, so that’s probably not needed.@JorgeBucaran I don’t really have a simple proposal for using
resolve
unless we want to allow for multiple data parameters toemit
. Probably not worth it.I’m torn about this issue since
events.action
is needed for some devtool/test use cases, but not as useful in production. 🤔