So I’m playing around a bit with Observables, and I came over some strange behavior, here’s a small example:
<Page ux:Class="TestPage">
<JavaScript>
var Observable = require("FuseJS/Observable");
var foo = Observable({ bar: { baz: "baz" } });
var bar = foo.map(function(x) { return x.bar; });
module.exports.baz = bar.map(function(x) { return x.baz; });
foo.value.bar.baz = "meow";
//bar.value.baz = "woof"; // TypeError: Cannot set property 'baz' of undefined. Also cats > dogs
</JavaScript>
<StackPanel>
<Text Value="{baz}"/>
</StackPanel>
</Page>
What I don’t understand is why does the commented statement fail? The way I understand this the variable bar
is supposed to be mapped to an observable of foo.value.bar
, yet bar.value
is undefined?