HenrikJoreteg / redux-bundler

Compose a Redux store out of smaller bundles of functionality.
https://reduxbundler.com
583 stars 46 forks source link

BATCH_ACTIONS prevent cacheBundle persistence #39

Open radebrecht opened 5 years ago

radebrecht commented 5 years ago

A bundle X dispatches a BATCH_ACTION, containing action A from bundle Y and action B from bundle Z. Both A and B are marked as persistenceActions in their respective bundles. Problem: the BATCH_ACTION correctly executes A and B, but nothing is persisted.

It seems that when actions are combined into BATCH_ACTIONS, the persistenceActions option of the individual actions are ignored.

HenrikJoreteg commented 5 years ago

Ah, that's an interesting case. Yeah, so since the middleware only looks at the actions coming through, unless the persistActions included BATCH_ACTIONS it wouldn't know to persist.

This could be mitigated, but would also require a change to redux-persist-middleware.

I agree it would be nice if this just worked, I'll see if I can find time to do this at some point. Or you're welcome to.

Essentially you'd need to change redux-bundler's BATCH_ACTIONS to attach the action types it's including as a property of the action. I'd suggest ._batchedActions. Then, redux-persist-middleware would also have to look for that property of the action.