How to use objects in markup

Hi community

I’m trying to output values from object in markup. Here is snippet what I’ve tried so far

<JavaScript>
    var Observable = require("FuseJS/Observable");
    var GeoLocation = require("FuseJS/GeoLocation");

    var continuousLocation = Observable("");
    GeoLocation.onChanged = function(location) {
        continuousLocation.value = location;
    };
    module.exports = {
        continuousLocation: continuousLocation
    };
</JavaScript>

<Text Value="{continuousLocation.latitude}" />

Is this kind of approach somehow possible or what is the correct way to handle objects in markup ?

Hi!

This approach looks fine. Are you having problems with it?

Yes I have. In example, line:

<Text Value="{continuousLocation.latitude}" />

Doesn’t ouput anything.

Geolocation.onChanged gets fired since this one:

var continuousLocationJSON = Observable("");
GeoLocation.onChanged = function(location) {
    continuousLocation.value = location;
    console.log(continuousLocation.value.latitude);
    console.log(continuousLocation.value.longitude);

    continuousLocationJSON.value = JSON.stringify(location);
};

module.exports = {
    continuousLocationJSON: continuousLocationJSON,
    continuousLocation: continuousLocation};
<Text Value="{continuousLocationJSON}" />

works like expected, both markup and console shows up correctly. But if I try with

<Text Value="{continuousLocation.latitude}" />

I get nothing.

Update with this one. Got this working with kind help from fellow in Slack.

I had

var continuousLocation = Observable("");

should be

var continuousLocation = Observable();