diff --git a/lib/realm.js b/lib/realm.js index d9eeb336..aecc56de 100644 --- a/lib/realm.js +++ b/lib/realm.js @@ -125,7 +125,10 @@ Object.defineProperties(Realm, { set: util.setterForProperty('defaultPath'), }, clearTestState: { - value: rpc.clearTestState, + value: function() { + util.clearMutationListeners(); + rpc.clearTestState(); + }, }, }); diff --git a/lib/util.js b/lib/util.js index 6ea4f95c..5733e54d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -8,9 +8,10 @@ const constants = require('./constants'); const rpc = require('./rpc'); const {keys} = constants; -const mutationListeners = {}; +let mutationListeners = {}; module.exports = { + clearMutationListeners, fireMutationListeners, createList, createMethods, @@ -31,6 +32,10 @@ function removeMutationListener(realmId, callback) { } } +function clearMutationListeners() { + mutationListeners = {}; +} + function fireMutationListeners(realmId) { let listeners = mutationListeners[realmId]; if (listeners) {