FormidableLabs / freactal

Clean and robust state management for React and React-like libs.
MIT License
1.65k stars 46 forks source link

Providing effect payload and name to middleware #33

Open aweary opened 7 years ago

aweary commented 7 years ago

Currently, middleware is just invoked with the entire state tree and effects list on every update. Middleware is especially useful when it can respond to a specific subset of effects, as well as know what that effect contained.

The existing recommendation is to just overwrite the effects with a wrapping utility, but that doesn't seem consistent with what a middleware API should provide since that means you'd be redefining your effects every time an effect is triggered, which I can't imagine is great for performance either. You want your middleware to get the data it needs by default as well.

Can middleware be invoked at a different point in the code path so it has access to effect names and effect payload without having to redefine effects on every update?

divmain commented 7 years ago

More discussion on this going on in #36. Would love your thoughts on it @aweary.