Project needs reload to work

Hi, I have some pages, with own javascript files and I use navigator for navigating between them. I also have one main.js file inside MainView.ux which I use like a storage for global variables.

Here is the problem : I have to press CTRL+R to make the App work. It doesnt work on first start. After reload everything works like a charm and I can change the variable realtime.

main.js (global variable)

settings.js (here i change the value of global variable)

Setting.ux (here i display the global variable from main.js, also contains input for variable value)

For better understaning of my problem: The value of TextInput is displayed on the same page as the TextInput is. I can write anything and the text displayed in UX is not changing. After I CTRL+R my app, the value is changed realtime as I type inside TextInput (this is how it should work).

I dont know where the problem is, but i think it may be something with Navigator component.

Edit : Discovered that the value in script changes, but is not displayed in UX.

Sounds a little odd indeed. Unfortunately it’s almost impossible to help you debug this without looking at the source. Can you produce a minimal project that reproduces this behavior and share it with us? If you don’t want to post it here in the forum, you can use this link to upload it to the dev team privately:

Thank you for answer, I uploaded the necessary files on github : FuseToolsApp

The problem is on Settings page. If you click on any of values displayed there, nothing happens. Then reload and it works .

Any help here?

Hi Martin,

From looking at your code, it seems you are basing it on a wrong assumption:

When you do <JavaScript File="main.js"> in your MainView.ux, this becomes a different module from when you require() it inside your settings page, so the numOfQuestions observable is not truly shared between the pages, as you seem to expect.

To solve this, decide for each JS file wether this is one you will require() or use on a JavaScript tag. I suggesting renaming main.js to data.js and instead doing this in your MainView.ux:

        module.exports = require("data");

The rule is: When you require() the same module mulitple times, you get the same object. But when you use <JavaScript>, it becomes a clone of the module for each instance.