Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

blacklist doesn't work #82

Closed
john916zhang opened this issue Jan 22, 2016 · 4 comments
Closed

blacklist doesn't work #82

john916zhang opened this issue Jan 22, 2016 · 4 comments

Comments

@john916zhang
Copy link

I used the following code to exclude those actions. The strange thing is: TAB_CHANGE, SEGMENT_CHANGE don't trigger SAVE action, but DOWNLOAD_UPDATE action still triggers SAVE action. The difference between them is: DOWNLOAD_UPDATE action is very frequent.

const middleware = storage.createMiddleware(engine, [
  actionTypes.TAB_CHANGE, 
  actionTypes.DOWNLOAD_UPDATE,
  actionTypes.SEGMENT_CHANGE])
@john916zhang
Copy link
Author

I add several console.log to debug this issue.

                var isOnBlacklist = blacklistedActions.indexOf(action.type) !== -1;
                var isOnWhitelist = actionWhitelist.length === 0 ? true // Don't filter if the whitelist is empty
                : actionWhitelist.indexOf(action.type) !== -1;

                console.log(blacklistedActions)
                console.log(action.type)
                console.log(isOnBlacklist)            

The following is my observation:

2016-01-22 9 10 59

DOWNLOAD_UPDATE doesn't trigger SAVE. But there is another action right after DOWNLOAD_UPDATE. And its type is 'undefined'

@john916zhang
Copy link
Author

Then I output that extra action:

2016-01-22 9 16 31

@john916zhang
Copy link
Author

The workround is check if the action type is undefined:

                var result = next(action);

                if (! action.type)
                    return result

@michaelcontento
Copy link
Owner

Thank you for reporting this!

With 4a12182 redux-storage will now a) ignore invalid structured action objects and b) warn about them if NODE_ENV != 'production'.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants