From 50c4da8e1c224424f34019ce83ba2d1984d44d28 Mon Sep 17 00:00:00 2001 From: DingChao <270422767@qq.com> Date: Sun, 15 Jul 2018 13:17:49 +0800 Subject: [PATCH] add blacklist which tirgger listeners immediately --- src/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 88b069d..d5faa0c 100755 --- a/src/index.js +++ b/src/index.js @@ -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.include(type)) { + notifyListeners(); + } else { + notifyListenersBatched(); + } return res; }