Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Global Variable that maintains its value between screens

ANSWERED

Hi,

Developed a clockface with global variable that increases onclick of a button.

Works perfectly until I move to a new screen - for example swipe upward then select back button, then the variable is reset.  Is there a way to keep the variable value after returning to the clockface?

 

let amountX = 0;

 

mybutton.onclick = function (e) {

amountX++;

}

 

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

When you swipe up, your clock gets closed and another app gets opened. Pressing back closes that app and re-launches your clock. If you want to maintain state, you need to save it to a file using the FS API.

View best answer in original post

Best Answer
2 REPLIES 2

When you swipe up, your clock gets closed and another app gets opened. Pressing back closes that app and re-launches your clock. If you want to maintain state, you need to save it to a file using the FS API.

Best Answer

Thanks Liam, will try it out and let all know. Cheers

Best Answer
0 Votes