Skip to content

Is there anyway to keep persistent, global variables? #7740

Answered by gfwilliams
kkayam asked this question in Bangle.js
Discussion options

You must be logged in to vote

I'm afraid Storage is the only way, but you can store in RAM and then write to Storage in E.on("kill", function() { ... }) to reduce the file writes performed.

If you're going between apps that support 'fast load' then the JS instance won't be torn down between either - so for instance flipping between the default clock/launcher and then loading the first app your code will stay running - it's just when you exit that app (if it doesn't support fast load, which most don't) that you'd have to write to storage

Persistent Storage is something that has been requested and it might get added at some point, but restarting from scratch for each app was a very deliberate choice - because anyone can…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kkayam
Comment options

Answer selected by kkayam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants