Skip to content

Commit

Permalink
Perf: place global list of actions into instance
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Apr 26, 2015
1 parent 5237b69 commit dca4e7a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/alt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const {
snapshot
} = StateFunctions

const GlobalActionsNameRegistry = {}
const ACTIONS_REGISTRY = Symbol()

class Alt {
constructor(config = {}) {
Expand All @@ -41,6 +41,7 @@ class Alt {
this.actions = {}
this.stores = {}
this.storeTransforms = config.storeTransforms || []
this[ACTIONS_REGISTRY] = {}
this[LAST_SNAPSHOT] = this[INIT_SNAPSHOT] = '{}'
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dca4e7a

Please sign in to comment.