Closed soulprovidr closed 4 years ago
Hello @soulprovidr,
Baobab indeed only lets you listen to any change on the tree at each tick, so if you need to know which specific action was fired it is a bit tricky indeed.
One solution I was considering is to override the dispatch implementation so an event is automatically emitted, and then add an extra method to the Baobab object to allow observers to subscribe to specific actions.
Your solution seems to be a good one that does not require to change anything to the libraries.
Hi @Yomguithereal,
Thanks for your feedback, I will try to add this functionality without modifying the library code.
For now I will close this issue and re-open it if I need more direction.
👍
Just wondering if anyone has successfully implemented Redux-esque middleware in an application using
baobab-react
.Currently I am using a
emmett
instance to fire events manually, but it would be nice to be able to listen todispatch
-ed actions without needing to add extra code.One solution I was considering is to override the
dispatch
implementation so an event is automatically emitted, and then add an extra method to theBaobab
object to allow observers to subscribe to specific actions.Any advice here? Is there another option that doesn't require modification of
baobab
andbaobab-react
?(If there is interest, I may try to submit a PR implementing this idea).