Skip to content

Commit

Permalink
Fix coverage add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Apr 15, 2015
1 parent d024b91 commit d370643
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 210 deletions.
72 changes: 36 additions & 36 deletions dist/alt-browser-with-addons.js
Expand Up @@ -1011,7 +1011,7 @@ var ACTION_UID = Symbol("the actions uid name");
var ALL_LISTENERS = Symbol("name of listeners");
var EE = Symbol("event emitter instance");
var INIT_SNAPSHOT = Symbol("init snapshot storage");
var IS_DISPATCHING = Symbol();
var IS_ACTION_LISTENER = Symbol();
var LAST_SNAPSHOT = Symbol("last snapshot storage");
var LIFECYCLE = Symbol("store lifecycle listeners");
var LISTENERS = Symbol("stores action listeners storage");
Expand All @@ -1036,6 +1036,30 @@ function uid(container, name) {
return key;
}

function doSetState(store, storeInstance, nextState) {
if (!nextState) {
return;
}

if (!store.alt.dispatcher.isDispatching()) {
throw new Error("You can only use setState while dispatching");
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof nextState === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

// If we are not in an action listener then just set the state and emit
// a change.
if (!storeInstance[IS_ACTION_LISTENER]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
store.emitChange();
}
}

/* istanbul ignore next */
function NoopClass() {}

Expand Down Expand Up @@ -1077,8 +1101,9 @@ var AltStore = (function () {
if (typeof model.beforeEach === "function") {
model.beforeEach(payload.action.toString(), payload.data, _this8[STATE_CONTAINER]);
}

if (model[LISTENERS][payload.action]) {
_this8[IS_DISPATCHING] = true;
_this8[IS_ACTION_LISTENER] = true;
_this8[NEXT_STATE] = null;
var result = false;

Expand All @@ -1092,14 +1117,17 @@ var AltStore = (function () {
}
}

if (result !== false && _this8[NEXT_STATE] === null) {
_this8.emitChange();
} else if (_this8[NEXT_STATE]) {
if (_this8[NEXT_STATE]) {
_this8[STATE_CONTAINER] = _this8[NEXT_STATE];
}

if (result !== false || _this8[NEXT_STATE]) {
_this8.emitChange();
}
_this8[IS_DISPATCHING] = false;

_this8[IS_ACTION_LISTENER] = false;
}

if (typeof model.afterEach === "function") {
model.afterEach(payload.action.toString(), payload.data, _this8[STATE_CONTAINER]);
}
Expand Down Expand Up @@ -1344,21 +1372,7 @@ var createStoreFromObject = function (alt, StoreModel, key, saveStore) {
return storeInstance;
},
setState: function setState(nextState) {
if (!nextState) {
return;
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof state === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

if (!storeInstance[IS_DISPATCHING]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
this.emitChange();
}
doSetState(this, storeInstance, nextState);
}
}, StoreMixinListeners, StoreMixinEssentials, StoreModel);

Expand Down Expand Up @@ -1456,21 +1470,7 @@ var Alt = (function () {
return storeInstance;
},
setState: function setState(nextState) {
if (!nextState) {
return;
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof state === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

if (!storeInstance[IS_DISPATCHING]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
this.emitChange();
}
doSetState(this, storeInstance, nextState);
}
});

Expand Down
72 changes: 36 additions & 36 deletions dist/alt-browser.js
Expand Up @@ -755,7 +755,7 @@ var ACTION_UID = Symbol("the actions uid name");
var ALL_LISTENERS = Symbol("name of listeners");
var EE = Symbol("event emitter instance");
var INIT_SNAPSHOT = Symbol("init snapshot storage");
var IS_DISPATCHING = Symbol();
var IS_ACTION_LISTENER = Symbol();
var LAST_SNAPSHOT = Symbol("last snapshot storage");
var LIFECYCLE = Symbol("store lifecycle listeners");
var LISTENERS = Symbol("stores action listeners storage");
Expand All @@ -780,6 +780,30 @@ function uid(container, name) {
return key;
}

function doSetState(store, storeInstance, nextState) {
if (!nextState) {
return;
}

if (!store.alt.dispatcher.isDispatching()) {
throw new Error("You can only use setState while dispatching");
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof nextState === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

// If we are not in an action listener then just set the state and emit
// a change.
if (!storeInstance[IS_ACTION_LISTENER]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
store.emitChange();
}
}

/* istanbul ignore next */
function NoopClass() {}

Expand Down Expand Up @@ -821,8 +845,9 @@ var AltStore = (function () {
if (typeof model.beforeEach === "function") {
model.beforeEach(payload.action.toString(), payload.data, _this8[STATE_CONTAINER]);
}

if (model[LISTENERS][payload.action]) {
_this8[IS_DISPATCHING] = true;
_this8[IS_ACTION_LISTENER] = true;
_this8[NEXT_STATE] = null;
var result = false;

Expand All @@ -836,14 +861,17 @@ var AltStore = (function () {
}
}

if (result !== false && _this8[NEXT_STATE] === null) {
_this8.emitChange();
} else if (_this8[NEXT_STATE]) {
if (_this8[NEXT_STATE]) {
_this8[STATE_CONTAINER] = _this8[NEXT_STATE];
}

if (result !== false || _this8[NEXT_STATE]) {
_this8.emitChange();
}
_this8[IS_DISPATCHING] = false;

_this8[IS_ACTION_LISTENER] = false;
}

if (typeof model.afterEach === "function") {
model.afterEach(payload.action.toString(), payload.data, _this8[STATE_CONTAINER]);
}
Expand Down Expand Up @@ -1088,21 +1116,7 @@ var createStoreFromObject = function (alt, StoreModel, key, saveStore) {
return storeInstance;
},
setState: function setState(nextState) {
if (!nextState) {
return;
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof state === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

if (!storeInstance[IS_DISPATCHING]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
this.emitChange();
}
doSetState(this, storeInstance, nextState);
}
}, StoreMixinListeners, StoreMixinEssentials, StoreModel);

Expand Down Expand Up @@ -1200,21 +1214,7 @@ var Alt = (function () {
return storeInstance;
},
setState: function setState(nextState) {
if (!nextState) {
return;
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof state === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

if (!storeInstance[IS_DISPATCHING]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
this.emitChange();
}
doSetState(this, storeInstance, nextState);
}
});

Expand Down
72 changes: 36 additions & 36 deletions dist/alt-with-runtime.js
Expand Up @@ -12,7 +12,7 @@ var ACTION_UID = Symbol("the actions uid name");
var ALL_LISTENERS = Symbol("name of listeners");
var EE = Symbol("event emitter instance");
var INIT_SNAPSHOT = Symbol("init snapshot storage");
var IS_DISPATCHING = Symbol();
var IS_ACTION_LISTENER = Symbol();
var LAST_SNAPSHOT = Symbol("last snapshot storage");
var LIFECYCLE = Symbol("store lifecycle listeners");
var LISTENERS = Symbol("stores action listeners storage");
Expand All @@ -37,6 +37,30 @@ function uid(container, name) {
return key;
}

function doSetState(store, storeInstance, nextState) {
if (!nextState) {
return;
}

if (!store.alt.dispatcher.isDispatching()) {
throw new Error("You can only use setState while dispatching");
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof nextState === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

// If we are not in an action listener then just set the state and emit
// a change.
if (!storeInstance[IS_ACTION_LISTENER]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
store.emitChange();
}
}

/* istanbul ignore next */
function NoopClass() {}

Expand Down Expand Up @@ -78,8 +102,9 @@ var AltStore = (function () {
if (typeof model.beforeEach === "function") {
model.beforeEach(payload.action.toString(), payload.data, _this8[STATE_CONTAINER]);
}

if (model[LISTENERS][payload.action]) {
_this8[IS_DISPATCHING] = true;
_this8[IS_ACTION_LISTENER] = true;
_this8[NEXT_STATE] = null;
var result = false;

Expand All @@ -93,14 +118,17 @@ var AltStore = (function () {
}
}

if (result !== false && _this8[NEXT_STATE] === null) {
_this8.emitChange();
} else if (_this8[NEXT_STATE]) {
if (_this8[NEXT_STATE]) {
_this8[STATE_CONTAINER] = _this8[NEXT_STATE];
}

if (result !== false || _this8[NEXT_STATE]) {
_this8.emitChange();
}
_this8[IS_DISPATCHING] = false;

_this8[IS_ACTION_LISTENER] = false;
}

if (typeof model.afterEach === "function") {
model.afterEach(payload.action.toString(), payload.data, _this8[STATE_CONTAINER]);
}
Expand Down Expand Up @@ -343,21 +371,7 @@ var createStoreFromObject = function (alt, StoreModel, key, saveStore) {
return storeInstance;
},
setState: function setState(nextState) {
if (!nextState) {
return;
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof state === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

if (!storeInstance[IS_DISPATCHING]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
this.emitChange();
}
doSetState(this, storeInstance, nextState);
}
}, StoreMixinListeners, StoreMixinEssentials, StoreModel);

Expand Down Expand Up @@ -453,21 +467,7 @@ var Alt = (function () {
return storeInstance;
},
setState: function setState(nextState) {
if (!nextState) {
return;
}

storeInstance[NEXT_STATE] = storeInstance[NEXT_STATE] || {};
if (typeof state === "function") {
assign(storeInstance[NEXT_STATE], nextState(storeInstance[STATE_CONTAINER]));
} else {
assign(storeInstance[NEXT_STATE], nextState);
}

if (!storeInstance[IS_DISPATCHING]) {
storeInstance[STATE_CONTAINER] = storeInstance[NEXT_STATE];
this.emitChange();
}
doSetState(this, storeInstance, nextState);
}
});

Expand Down

0 comments on commit d370643

Please sign in to comment.