diff --git a/src/observe.js b/src/observe.js index c555570..68c124f 100644 --- a/src/observe.js +++ b/src/observe.js @@ -922,11 +922,12 @@ }, getValue: function() { - return this.observable_.getValue(); + return this.getValueFn_(this.observable_.getValue()); }, discardChanges: function() { - return this.getValueFn_(this.observable_.discardChanges()); + this.value_ = this.getValueFn_(this.observable_.discardChanges()); + return this.value_; }, deliver: function() { @@ -934,11 +935,9 @@ }, setValue: function(value) { - this.value_ = this.setValueFn_(value); - if (this.dontPassThroughSet_ || !this.observable_.setValue) - return; - - return this.observable_.setValue(this.value_); + value = this.setValueFn_(value); + if (!this.dontPassThroughSet_ && this.observable_.setValue) + return this.observable_.setValue(value); }, close: function() { diff --git a/tests/test.js b/tests/test.js index b5d2e86..b96d9f3 100644 --- a/tests/test.js +++ b/tests/test.js @@ -333,8 +333,12 @@ suite('ObserverTransform', function() { observer.setValue(2); assert.strictEqual(obj.foo, 1); - assert.strictEqual(2, observer.discardChanges()); - assertNoChanges(); + assert.strictEqual(2, observer.getValue()); + assertPathChanges(2, 4); + + obj.foo = 10; + assert.strictEqual(20, observer.getValue()); + assertPathChanges(20, 2); observer.close(); });