-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Hi. I've designed a custom redux middleware in a attempt to really push all side-effects away from my view code by means of redux-saga. I am basically appending a FIFO "TaskReducer" to my single redux store, and handling any QUEUE actions with it:
//queue action creator
function queue( task ){
return {
type: 'QUEUE',
payload: task
};
};
//taskMiddleware
export default store => next => action => {
const result = next(queue(action));
return result;
}
//and a TaskReducer that merges repeated tasks in a meaningful way (e.g. a FIFO queue) ...
I find this way of delegating tasks quite convenient for performance reasons. However, since the QUEUE action plays as any other action in redux, any store listeners (e.g. hundreds of connected components) will eventually waste time on it, and even DevTools won't work properly since I am not interested in replaying side-effects...
So I was wondering if this situation is of any interest for this repository, as it seems to me that this is the correct place to implement a solution for "undesired action subscriptions".
Perhaps passing the dispatched action as an argument for the batch function would solve this? That way we could easily check for the action type and decide whether we should notify the listeners or not:
const store = batchedSubscribe((notify, action) => {
if(action.type !== QUEUE)
requestAnimationFrame(notify);
})(createStore)(reducers)
Anyways, is this worth pull requesting?