From dca4e7a09fa19780b60e42ab3f71792ea3907284 Mon Sep 17 00:00:00 2001 From: Josh Perez Date: Sat, 25 Apr 2015 22:03:26 -0700 Subject: [PATCH] Perf: place global list of actions into instance --- src/alt/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/alt/index.js b/src/alt/index.js index b1b984f3..3fec0b62 100644 --- a/src/alt/index.js +++ b/src/alt/index.js @@ -30,7 +30,7 @@ const { snapshot } = StateFunctions -const GlobalActionsNameRegistry = {} +const ACTIONS_REGISTRY = Symbol() class Alt { constructor(config = {}) { @@ -41,6 +41,7 @@ class Alt { this.actions = {} this.stores = {} this.storeTransforms = config.storeTransforms || [] + this[ACTIONS_REGISTRY] = {} this[LAST_SNAPSHOT] = this[INIT_SNAPSHOT] = '{}' } @@ -93,8 +94,8 @@ class Alt { } createAction(name, implementation, obj) { - const actionId = uid(GlobalActionsNameRegistry, name) - GlobalActionsNameRegistry[actionId] = 1 + const actionId = uid(this[ACTIONS_REGISTRY], name) + this[ACTIONS_REGISTRY][actionId] = 1 const actionName = Symbol.for(actionId) // Wrap the action so we can provide a dispatch method