Comparing version 0.4.4 to 0.4.5
{ | ||
"name": "cerebral", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "An intelligent react application framework", | ||
@@ -5,0 +5,0 @@ "main": "src/Cerebral.js", |
@@ -158,3 +158,3 @@ 'use strict'; | ||
if (mapValue) { | ||
return mapValue; | ||
return mapValue[0]; | ||
} | ||
@@ -161,0 +161,0 @@ |
@@ -20,2 +20,3 @@ "use strict"; | ||
runningSignal: null, | ||
subSignal: null, | ||
nextRef: 0, | ||
@@ -22,0 +23,0 @@ currentSignal: eventStore.currentIndex, |
@@ -12,2 +12,3 @@ "use strict"; | ||
var callback = description.get; | ||
var values = []; | ||
var deps = depPaths; | ||
@@ -39,4 +40,2 @@ path = (typeof path === 'string' ? [path] : path).slice(); | ||
setValue(prevResult); | ||
} else { | ||
setValue(prevResult); | ||
} | ||
@@ -46,13 +45,23 @@ }; | ||
var setValue = function(value) { | ||
var mapPath = maps; | ||
var pathCopy = path.slice(); | ||
while (pathCopy.length) { | ||
mapPath = mapPath[pathCopy.shift()] = pathCopy.length ? {} : value; | ||
values.unshift(value); | ||
// When remembering subsignals that are async we need to reverse the values | ||
// as the async value should be picked instead. Might need to check if this | ||
// signal actually is async | ||
if (!!helpers.subSignal && store.isRemembering) { | ||
values.reverse(); | ||
} | ||
}; | ||
var mapPath = maps; | ||
var pathCopy = path.slice(); | ||
while (pathCopy.length) { | ||
mapPath = mapPath[pathCopy.shift()] = pathCopy.length ? {} : values; | ||
} | ||
setValue(description.value); | ||
store.on('mapUpdate', update); | ||
helpers.mapCallbacks.push(update); | ||
@@ -59,0 +68,0 @@ }; |
@@ -13,3 +13,3 @@ "use strict"; | ||
var executionArray = callbacks.slice(); | ||
var signalIndex = helpers.eventStore.willKeepState ? | ||
var signalIndex = helpers.eventStore.willKeepState ? | ||
!!helpers.runningSignal ? helpers.eventStore.currentIndex : ++helpers.eventStore.currentIndex : 0; | ||
@@ -34,2 +34,5 @@ var initiatedSignal = helpers.runningSignal || name; | ||
helpers.runningSignal = helpers.runningSignal || name; | ||
helpers.subSignal = helpers.runningSignal === name ? null : name; | ||
var signalArgs = [].slice.call(arguments); | ||
@@ -85,2 +88,3 @@ var callback = executionArray.shift(); | ||
if (callbacks.indexOf(callback) !== 0) { | ||
store.emit('mapUpdate'); | ||
!helpers.eventStore.isSilent && store.emit('update'); | ||
@@ -113,6 +117,4 @@ } | ||
// Have to update again after an async action | ||
var result = execute(result); | ||
return execute(result); | ||
return result; | ||
}).catch(function(err) { | ||
@@ -133,4 +135,4 @@ helpers.eventStore.addAsyncSignal({ | ||
} else { | ||
store.emit('mapUpdate'); | ||
!helpers.eventStore.isSilent && store.emit('update'); | ||
store.emit('mapUpdate'); | ||
helpers.runningSignal = null; | ||
@@ -142,3 +144,2 @@ } | ||
if (!helpers.runningSignal) { | ||
helpers.runningSignal = helpers.runningSignal || name; | ||
helpers.eventStore.addSignal(signal); | ||
@@ -145,0 +146,0 @@ } |
@@ -56,6 +56,5 @@ "use strict"; | ||
} | ||
if (this.currentIndex < this.signals.length - 1) { | ||
this.signals.splice(this.currentIndex + 1, this.signals.length - this.currentIndex); | ||
if (this.currentIndex <= this.signals.length - 1) { | ||
this.signals.splice(this.currentIndex, this.signals.length - this.currentIndex); | ||
} | ||
@@ -166,3 +165,3 @@ this.signals.push(signal); | ||
store.isRemembering = false; | ||
store.emit('update'); | ||
store.emit('eventStoreUpdate'); | ||
@@ -169,0 +168,0 @@ return store; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164900
2627