Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tappleby/redux-batched-subscribe
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: dingchaoyan1983/redux-batched-subscribe
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 15, 2018

  1. Copy the full SHA
    50c4da8 View commit details
  2. eslint

    dingchaoyan1983 committed Jul 15, 2018
    Copy the full SHA
    e331eb9 View commit details
  3. test fix

    dingchaoyan1983 committed Jul 15, 2018
    Copy the full SHA
    e574e31 View commit details
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/index.js
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function batchedSubscribe(batch) {
export function batchedSubscribe(batch, blacklist = []) {
if (typeof batch !== 'function') {
throw new Error('Expected batch to be a function.');
}
@@ -51,8 +51,14 @@ export function batchedSubscribe(batch) {
const subscribeImmediate = store.subscribe;

function dispatch(...dispatchArgs) {
const [action] = dispatchArgs;
const { type } = action;
const res = store.dispatch(...dispatchArgs);
notifyListenersBatched();
if (blacklist.includes(type)) {
notifyListeners();
} else {
notifyListenersBatched();
}
return res;
}