Closed dmicic closed 4 years ago
Sounds great. One idea not attached to it though. Would it be good to provide a functional subscriber to remove the boilerplate?
const state = useBusReducer.configure({
subscriber: eventSubscriber("task.**", "signout")
})(reducer, InitialState);
Maybe there is a better name than eventSubscriber
?
+1 for the functional subscriber. And I think the name is good.
The bus should allow to subscribe to a list of events.
Example:
This his helpful in scenarios as above, where the reducer needs to know about a certain event like "signOut" that is not been raised under the event name prefix "task" in order to clean up the state etc.