Skip to content

Commit

Permalink
Fixed #558: boxed observables should stay boxed observables
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Sep 23, 2016
1 parent 3bac300 commit 2c77e7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 2.5.2

* Observable objects can now have a type: `IObservableObject`, see [#484](https://github.com/mobxjs/mobx/pull/484) by @spiffytech
* Restored 2.4 behavior of boxed observables inside observable objects, see [#558](https://github.com/mobxjs/mobx/issues/558)

# 2.5.1

Expand Down
9 changes: 4 additions & 5 deletions src/types/observableobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ export function defineObservableProperty(adm: ObservableObjectAdministration, pr
let name = `${adm.name}.${propName}`;
let isComputed = true;

if (newValue instanceof ObservableValue) {
observable = newValue;
newValue.name = name;
isComputed = false;
} else if (newValue instanceof ComputedValue) {
if (newValue instanceof ComputedValue) {
// desugger computed(getter, setter)
// TODO: deprecate this and remove in 3.0, to keep them boxed
// get / set is now the idiomatic syntax for non-boxed computed values
observable = newValue;
newValue.name = name;
if (!newValue.scope)
Expand Down
10 changes: 10 additions & 0 deletions test/observables.js
Original file line number Diff line number Diff line change
Expand Up @@ -1892,3 +1892,13 @@ test('helpful error for self referencing setter', function(t) {

t.end()
})

test('#558 boxed observables stay boxed observables', function(t) {
var a = observable({
x: observable(3)
})

t.equal(typeof a.x, "object")
t.equal(typeof a.x.get, "function")
t.end()
})

0 comments on commit 2c77e7e

Please sign in to comment.