# Observables, map and such

**URL:** <https://forums.fusetools.com/t/observables-map-and-such/6730>\
**Category:** How-to Discussions\
**Created:** [May 30, 2017, 2:01pm UTC](https://forums.fusetools.com/t/observables-map-and-such/6730 "2017-05-30T14:01:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eivind\_Samuelsen](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@Eivind\_Samuelsen](https://forums.fusetools.com/u/Eivind_Samuelsen)\
**Post date:** [May 30, 2017, 2:01pm UTC](https://forums.fusetools.com/t/observables-map-and-such/6730/1 "2017-05-30T14:01:56Z")

</div>

So I’m playing around a bit with Observables, and I came over some strange behavior, here’s a small example:

```auto
<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?

---

<div class="post-metadata">

**Author:** ![Jake\_Taylor](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jake_taylor/32/512_2.png) [@Jake\_Taylor](https://forums.fusetools.com/u/Jake_Taylor)\
**Post date:** [May 30, 2017, 2:05pm UTC](https://forums.fusetools.com/t/observables-map-and-such/6730/2 "2017-05-30T14:05:20Z")

</div>

`Observable`s will push values asynchronously, so I think what’s happening here is `foo` has not propagated its value to `bar` before `bar`'s `value` is attempted to be read.

---

<div class="post-metadata">

**Author:** ![Eivind\_Samuelsen](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@Eivind\_Samuelsen](https://forums.fusetools.com/u/Eivind_Samuelsen)\
**Post date:** [May 31, 2017, 9:36am UTC](https://forums.fusetools.com/t/observables-map-and-such/6730/3 "2017-05-31T09:36:59Z")

</div>

Ok, that makes perfects sense, thanks!

---

<div class="post-metadata">

**Author:** ![Jake\_Taylor](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jake_taylor/32/512_2.png) [@Jake\_Taylor](https://forums.fusetools.com/u/Jake_Taylor)\
**Post date:** [May 31, 2017, 10:41am UTC](https://forums.fusetools.com/t/observables-map-and-such/6730/4 "2017-05-31T10:41:37Z")

</div>

no worries 🙂
