diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2022-10-18 23:33:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 23:33:38 +0200 |
commit | 546d1908b15fc7c21b1b5f0109826fb03a5493fd (patch) | |
tree | c44daa3d0e550eaa3ff1397909bbc9564012d53f /README.md | |
parent | c4ce52bb45f0dcda8ea924694b48a8e0501d57c0 (diff) | |
download | FlightCore-546d1908b15fc7c21b1b5f0109826fb03a5493fd.tar.gz FlightCore-546d1908b15fc7c21b1b5f0109826fb03a5493fd.zip |
feat: Add persistent store (#16)
* refactor: Rename object field
So that is specifically references Northstar
* chore: Add plugin-store as npm dependency
* feat: Persistent storing selected NS release canal
* docs: Add explanation about persistent store
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -61,6 +61,37 @@ Note that you can adjust the behaviour of Tauri windows in `tauri.conf.json`, e. ] ``` +### Docs + +In regards to storing persistent data, FlightCore uses [`tauri-plugin-store`](https://github.com/tauri-apps/tauri-plugin-store). It's a key-value store accessed in frontend to load and store small amounts of data. + +The goal is to store as little data in there as possible and instead get the necessary info on app launch. +For example the install path of Titanfall2 should be inferred everytime on launch using Steam library or Origin, so that if the player changes the install location, there's no need to sync it up with the persistent store again. +The exception to this is when Steam/Origin is unable to find the install location and the user manually selected a location instead. In this case, we don't want to re-prompt the user on every launch of FlightCore to enter the Titanfall2 install location. + +**Usage example for `tauri-plugin-store`:** + +```typescript +// Import the lib +import { Store } from 'tauri-plugin-store-api'; +// Define a store based on filename to write to +const persistentStore = new Store('flight-core-settings.json'); + +// Save change in persistent store +await persistentStore.set('northstar-release-canal', { value: "NorthstarReleasecandidate" }); + +// Grab Northstar release canal value from store if exists +var persistent_northstar_release_canal = (await persistentStore.get('northstar-release-canal')) as any; +if(persistent_northstar_release_canal) { // For some reason, the plugin-store doesn't throw an eror but simply returns `null` when key not found + // Put value from peristent store into current store + state.northstar_release_canal = persistent_northstar_release_canal.value as string; +} +else { + console.log("Value not found in store"); +} + +``` + ### Building Release builds are generally done via CI. To build locally, make sure typescript is compiled (`./node_modules/.bin/rollup --config`), then run `npm run tauri build`. |