@mmckegg/mutant
Advanced tools
Comparing version 3.3.0 to 3.3.1
40
array.js
@@ -113,14 +113,27 @@ var Value = require('./value') | ||
observable.set = function (values) { | ||
var changed = false | ||
if (fixedIndexing) { | ||
var length = values && values.length || 0 | ||
for (var i = 0; i < length; i++) { | ||
if (!sources[i]) { | ||
var valueOrObs = getObsValue(values[i]) | ||
sources[i] = valueOrObs | ||
object[i] = resolve(valueOrObs) | ||
if (isObservable(values[i])) { | ||
if (values[i] !== sources[i]) { | ||
tryInvoke(releases[index]) | ||
sources[i] = values[i] | ||
changed = true | ||
if (binder.live) { | ||
releases[i] = bind(sources[i]) | ||
} | ||
} | ||
} else if (sources[i] && sources[i]._type === 'MutantArrayValue') { | ||
if (!isSame(sources[i](), values[i], comparer)) { | ||
sources[i].set(values[i]) | ||
changed = true | ||
} | ||
} else { | ||
tryInvoke(releases[index]) | ||
sources[i] = getObsValue(values[i]) | ||
changed = true | ||
if (binder.live) { | ||
releases[i] = bind(valueOrObs) | ||
releases[i] = bind(sources[i]) | ||
} | ||
} else { | ||
sources[i].set(values[i]) | ||
} | ||
@@ -130,7 +143,11 @@ } | ||
tryInvoke(releases[index]) | ||
changed = true | ||
} | ||
releases.length = length | ||
sources.length = length | ||
object.length = length | ||
binder.broadcast() | ||
if (changed) { | ||
releases.length = length | ||
sources.length = length | ||
object.length = length | ||
binder.broadcast() | ||
} | ||
} else { | ||
@@ -156,2 +173,3 @@ unlisten() | ||
valueOrObs = Value(valueOrObs) | ||
valueOrObs._type = 'MutantArrayValue' | ||
} | ||
@@ -158,0 +176,0 @@ return valueOrObs |
@@ -19,2 +19,5 @@ var addCollectionMethods = require('./lib/add-collection-methods') | ||
if (shouldUpdate(item, raw[i])) { | ||
if (raw[i].key() !== key) { | ||
raw[i].key.set(key) | ||
} | ||
if (raw[i].value !== item) { | ||
@@ -21,0 +24,0 @@ raw[i].value.set(item) |
{ | ||
"name": "@mmckegg/mutant", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "array.js", |
63357
2266