From 358e5dacf3ddb0f8d530b7453c0f68cf07fc3e15 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 2 Nov 2015 16:29:13 -0800 Subject: [PATCH] Add method to clear mutation listeners in RPC client --- lib/realm.js | 5 ++++- lib/util.js | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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) {