Skip to content

Commit

Permalink
add blacklist which tirgger listeners immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
dingchaoyan1983 committed Jul 15, 2018
1 parent 24efa85 commit 50c4da8
Showing 1 changed file with 8 additions and 2 deletions.
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.');
}
Expand Down Expand Up @@ -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.include(type)) {
notifyListeners();
} else {
notifyListenersBatched();
}
return res;
}

Expand Down

0 comments on commit 50c4da8

Please sign in to comment.