persistence
-
Working on a corporate project targeting Windows and iPads. I need a way to store basic user preferences and settings (like a config.ini). Electron has a couple of packages that look like they will work (
electron-store
,electron-settings
) and then Cordova hascordova-plugin-nativestorage
.Before rolling my own solution, does Quasar have plans for a persistence API? Are the above packages recommended for implementing persistence? Have I missed other options? Could this be implemented via an app extension?
-
@terrybradshaw I’m not doing Electron apps (yet) but for server apps there’s the DotEnv stuff. There’s an App Extension for it … actually 2 … I’ve no personal experience of them, but perhaps that’s what you need to look at …
-
@terrybradshaw i think vuex-persistedstate is enough for this. https://github.com/robinvdvleuten/vuex-persistedstate, even the Quasar wrappers for localStorage / sessionStorage is ok https://quasar.dev/quasar-plugins/web-storage#Introduction.
-
@digiproduct Thanks for this, I wasn’t familiar with dotenv but yes this is certainly useful. Unfortunately however it is not a full solution as you cannot edit values or write new ones at runtime. Turns out this is a real mess in Cordova. The plugin I referred to has a major issue about it simply not working on iOS 8+, and there’s been almost no activity in nearly a year – the project may be dead. Same with some other projects with native hooks into
NSUserDefaults
(iOS) andSharedPreferences
(Android).Then there are solutions which build upon LocalStorage, IndexedDB and/or WebSQL. Problem there is that iOS will simply delete this when a device is low on space (see the caveat halfway down the page here as an example: https://pouchdb.com/faq.html#data_limits). Doesn’t appear to be any workaround.
The only reliable solutions may be to go full SQLite or a custom config file. Remote or cloud may generally work too but not for this particular project. Still researching it. Thanks for the help.
-
@metalsadman Thank you, I wasn’t familiar with these packages either, they look useful and easy and would be great to stay within the Vue ecosystem. The problem here is relying on LocalStorage, which iOS seems to wipe out without warning when devices get low on disk space (see link in previous reply, or https://forum.ionicframework.com/t/ios-localstorage-persistence/20004/2). This doesn’t appear to be a problem on Android.
-
@terrybradshaw localstorage works on all platforms tho, so if you’re worried about it being erased by the os, i think you should have some api to save those settings in the backend, a simple check if those don’t exist in the vuex store then make a call to the backend to retrieve it. otherwise you’ll have to maintain each storage plugins for each every platform.
-
Turns out there’s already a Quasar plugin for Local or Session storage that I had not noticed before: https://quasar.dev/quasar-plugins/web-storage
This would still be subject to the iOS problem of randomly deleting data when low on storage space, but nevertheless it’s a plus that it is already built into the framework.