3.0.2 • Published 9 months ago

redux-duplicate-actions v3.0.2

Weekly downloads
21
License
MIT
Repository
github
Last release
9 months ago

Redux Duplicate Action Monitor

This is a redux middleware that detects duplicate actions & shows this in the console. Ideal for ensuring good redux practices. Development use only!

If there is a duplicate action you will see this in the browser console:

[redux-duplicate-actions] A duplicate action has been detected.
[redux-duplicate-actions] Unique action hash: e6d0f668
[redux-duplicate-actions] Unpacked action: {type: 'SET_DATA', payload: {…}}
[redux-duplicate-actions] Original action: {type: 'SET_DATA', payload: ƒ} // Read below

If your payload is a function the middleware we will attempt to unpack it and show you the actual data. It does this by simply running the function against store.getState(). So effectively action.payload(store.getState()). If this fails it will do the comparison as normal.

Supports Node 10.x +

Installation

Run this in the terminal:

npm install --save-dev redux-duplicate-actions

or

yarn add -D redux-duplicate-actions

Usage

Supported options:

fatal (type: boolean) - if true, will throw an error when a duplicate action is detected. Default is false.

logLevel (type: 'log' | 'warn' | 'error') - the level of logging to the console. Default is "warn".

payloadKey (type: string) - the key to use to get the payload for the redux action. Default is "payload".

unpackPayloadIfFunction (type: boolean) - if true, will attempt to unpack the payload if it is a function. Default is true.

if (__DEV__) {
  // To thrown fatal error on duplicate action
  const reduxDuplicateActions = require("redux-duplicate-actions")({
    fatal: true,
  });
  reduxMiddleware.push(reduxDuplicateActions);

  // To log duplicate action as warning
  const reduxDuplicateActions = require("redux-duplicate-actions")({
    fatal: false
  });
  reduxMiddleware.push(reduxDuplicateActions);
}

Test

Run the following commands to test the module:

yarn install && yarn test

Contributing

All contributions are very welcome, please read my CONTRIBUTING.md first. You can submit any ideas as pull requests or as GitHub issues. If you'd like to improve code, please feel free!

License

FOSSA Status

3.0.2

9 months ago

3.0.0

9 months ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

6 years ago

1.2.11

6 years ago

1.2.10

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago