Skip to content

Commit

Permalink
Allow unlimited bootstraps
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Feb 10, 2015
1 parent 6aa81e5 commit 0ba7b85
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 40 deletions.
9 changes: 0 additions & 9 deletions dist/alt-with-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var ACTION_DISPATCHER = Symbol("action dispatcher storage");
var ACTION_HANDLER = Symbol("action creator handler");
var ACTION_KEY = Symbol("holds the actions uid symbol for listening");
var ACTION_UID = Symbol("the actions uid name");
var BOOTSTRAP_FLAG = VariableSymbol("has bootstrap");
var EE = Symbol("event emitter instance");
var INIT_SNAPSHOT = Symbol("init snapshot storage");
var LAST_SNAPSHOT = Symbol("last snapshot storage");
Expand Down Expand Up @@ -111,7 +110,6 @@ var ActionCreator = (function () {
this[ACTION_DISPATCHER] = alt.dispatcher;
this[ACTION_UID] = name;
this[ACTION_HANDLER] = action.bind(this);
this[BOOTSTRAP_FLAG] = false;
this.actions = actions;
this.alt = alt;
}
Expand Down Expand Up @@ -384,13 +382,6 @@ var Alt = (function () {
store[LIFECYCLE].bootstrap();
}
});

if (typeof window !== "undefined") {
if (this[BOOTSTRAP_FLAG]) {
throw new ReferenceError("Stores have already been bootstrapped");
}
this[BOOTSTRAP_FLAG] = true;
}
},
writable: true,
configurable: true
Expand Down
9 changes: 0 additions & 9 deletions dist/alt.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var ACTION_DISPATCHER = Symbol("action dispatcher storage");
var ACTION_HANDLER = Symbol("action creator handler");
var ACTION_KEY = Symbol("holds the actions uid symbol for listening");
var ACTION_UID = Symbol("the actions uid name");
var BOOTSTRAP_FLAG = VariableSymbol("has bootstrap");
var EE = Symbol("event emitter instance");
var INIT_SNAPSHOT = Symbol("init snapshot storage");
var LAST_SNAPSHOT = Symbol("last snapshot storage");
Expand Down Expand Up @@ -115,7 +114,6 @@ var ActionCreator = (function () {
this[ACTION_DISPATCHER] = alt.dispatcher;
this[ACTION_UID] = name;
this[ACTION_HANDLER] = action.bind(this);
this[BOOTSTRAP_FLAG] = false;
this.actions = actions;
this.alt = alt;
}
Expand Down Expand Up @@ -388,13 +386,6 @@ var Alt = (function () {
store[LIFECYCLE].bootstrap();
}
});

if (typeof window !== "undefined") {
if (this[BOOTSTRAP_FLAG]) {
throw new ReferenceError("Stores have already been bootstrapped");
}
this[BOOTSTRAP_FLAG] = true;
}
},
writable: true,
configurable: true
Expand Down
9 changes: 0 additions & 9 deletions src/alt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ let ACTION_DISPATCHER = Symbol('action dispatcher storage')
let ACTION_HANDLER = Symbol('action creator handler')
let ACTION_KEY = Symbol('holds the actions uid symbol for listening')
let ACTION_UID = Symbol('the actions uid name')
let BOOTSTRAP_FLAG = VariableSymbol('has bootstrap')
let EE = Symbol('event emitter instance')
let INIT_SNAPSHOT = Symbol('init snapshot storage')
let LAST_SNAPSHOT = Symbol('last snapshot storage')
Expand Down Expand Up @@ -87,7 +86,6 @@ class ActionCreator {
this[ACTION_DISPATCHER] = alt.dispatcher
this[ACTION_UID] = name
this[ACTION_HANDLER] = action.bind(this)
this[BOOTSTRAP_FLAG] = false
this.actions = actions
this.alt = alt
}
Expand Down Expand Up @@ -333,13 +331,6 @@ your own custom identifier for each store`
store[LIFECYCLE].bootstrap()
}
})

if (typeof window !== 'undefined') {
if (this[BOOTSTRAP_FLAG]) {
throw new ReferenceError('Stores have already been bootstrapped')
}
this[BOOTSTRAP_FLAG] = true
}
}

// Instance type methods for injecting alt into your application as context
Expand Down
17 changes: 4 additions & 13 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,21 +364,12 @@ module.exports = {

'bootstrapping'() {
alt.bootstrap('{"MyStore":{"name":"bee"}}')
assert.equal(myStore.getState().name, 'bee', 'on server I can bootstrap many times')
assert.equal(myStore.getState().name, 'bee', 'I can bootstrap many times')

try {
// simulate the browser
global.window = {};

alt.bootstrap('{}')
// Attempting to bootstrap more than once
alt.bootstrap('{"MyStore":{"name":"bee"}}')
alt.bootstrap('{}')

assert.equal(true, false, 'I was able bootstrap more than once which is bad')
} catch (e) {
assert.equal(e instanceof ReferenceError, true, 'can only bootstrap once')
assert.equal(e.message, 'Stores have already been bootstrapped', 'can only bootstrap once')
}
alt.bootstrap('{"MyStore":{"name":"monkey"}}')
assert.equal(myStore.getState().name, 'monkey', 'I can bootstrap many times')
},

'variadic actions'() {
Expand Down

0 comments on commit 0ba7b85

Please sign in to comment.