HenrikJoreteg / redux-bundler

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

Add ignoreActions option to createDebugBundle #59

Closed malbonesi closed 4 years ago

malbonesi commented 4 years ago

Along the lines of ignoring APP_IDLE events, I thought this might be useful for other custom actions that are dispatched often.

createDebugBundle({ignoreActions: ['GEOLOCATION_SUCCESS']})

malbonesi commented 4 years ago

Thought there might have been an issue, but I think it's all good!

malbonesi commented 4 years ago

I was thinking logIdle should remain for code bases that are already using that, but maybe with this approach, logIdle could be removed and users should just include 'APP_IDLE' in ignoreBundles if they want to skip it?

HenrikJoreteg commented 4 years ago

what if instead of a list (or the logIdle) we just took an action filter function that you could provide? Then you can filter out whatever you want, for example:

// a single action
createDebugBundle({
  actionFilter: action => action.type !== 'APP_IDLE'
})
// a list of actions
createDebugBundle({
  actionFilter: action => ['SOME_ACTION', 'SOME_OTHER'].includes(action.type)
})
// only log a certain action you care about
createDebugBundle({
  actionFilter: action => action.type === 'BLAH'
})
// actions without payloads
createDebugBundle({
  actionFilter: action => !action.payload
})
HenrikJoreteg commented 4 years ago

I went ahead and did the actionFilter approach, but wanted to give you credit for the idea so I merged this, but modified it a bit. Thanks @malbonesi!

malbonesi commented 4 years ago

Ah very cool. For what it's worth, it feels a little strange having to use a function to configure something like this, but I don't actually have a different solution and this certainly offers the most control.

In any case, thanks for merging (and for this lib in general)! It looks like the documentation piece I added in docs/api/included-bundles.md is still there, btw :)

HenrikJoreteg commented 4 years ago

I hear ya, but the whole thing is for debugging so I think passing a function is pretty reasonable. It lets you do whatever. Write it once and forget it. Or you can customize it if you're trying to focus in on just a few things.

malbonesi commented 4 years ago

Yeah right on. Thanks :)