From 8e68f86bfef4c594af055e74861fb66b6fe50268 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Thu, 2 Mar 2017 12:26:42 +0000 Subject: [PATCH] Merge noSubscriptions and subscriptions options --- index.js | 2 +- test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 74a6a9b..de29079 100644 --- a/index.js +++ b/index.js @@ -160,7 +160,7 @@ function dispatcher (hooks) { _state = wrapHook(_state, initialStateWraps) } - if (!opts.noSubscriptions) subsCalled = true + if (opts.subscriptions !== false) subsCalled = true if (!opts.noReducers) reducersCalled = true if (!opts.noEffects) effectsCalled = true if (!opts.noState) stateCalled = true diff --git a/test.js b/test.js index fecdeb2..87fb5a6 100644 --- a/test.js +++ b/test.js @@ -137,6 +137,17 @@ tape('api: createSend = store.start(opts)', (t) => { const subscriptions = Object.keys(store._subscriptions) t.deepEqual(subscriptions.length, 0, 'no subscriptions registered') }) + + t.test('opts.subscriptions = true should register subs after initial call with subs disabled', + (t) => { + t.plan(1) + const store = barracks() + store.model({ subscriptions: { foo: noop } }) + store.start({ subscriptions: false }) + store.start() + const subscriptions = Object.keys(store._subscriptions) + t.deepEqual(subscriptions.length, 1, 'subscriptions registered') + }) }) tape('api: state = store.state()', (t) => {