I’ve been asked a couple of times, if it’s possible to store data on the device via DukeScript -
for example in order to store UI state. We’re currently exploring how to automate this tracking,
so you would only need to register your ViewModel once for automated persistence. A PersistenceManager
would then take care of persisting the model on every change of a Model Property.
For Performance reasons there would be a custom debounce threshold you can set to make sure changes are only persisted when input events have comleted.
Until we offer this as an API (Update: as of February 2017, there
is an easy way to get started via
Maven archetype 0.17 or newer version),
you might want a specific solution for your Application right now.
So here’s a starting point:
With this code you can store Strings, which is good enough, because ViewModels
can be serialized to JSON. So you can easily read and write your data:
This simple solution requires you to track changes in the model yourself and serialize the data.
By the way: A happy new Year to all friends of DukeScript!