harshkhandeparkar / tauri-settings Goto Github PK
View Code? Open in Web Editor NEWA user settings manager library for Tauri inspired by electron-settings.
Home Page: https://www.npmjs.com/package/tauri-settings
License: MIT License
A user settings manager library for Tauri inspired by electron-settings.
Home Page: https://www.npmjs.com/package/tauri-settings
License: MIT License
I have a pretty straightforward store using SettingsManager but I am getting an unhandled promise rejection saying the key does not exist
import { SettingsManager } from 'tauri-settings';
import { writable } from 'svelte/store';
type SettingsSchema = {
rootFolder: string;
};
const settingsManager = new SettingsManager<SettingsSchema>(
{
rootFolder: ''
},
{ fileName: 'rootfolder.json' }
);
const store = writable(
{
rootFolder: ''
},
() => {
settingsManager.initialize().then(async () => {
console.log('Setting Manager initialized');
/* Error thrown on the next line */
const rootFolderVal = await settingsManager.get('rootFolder');
store.set({ rootFolder: rootFolderVal });
});
}
);
const setRootFolder = async (value: string) => {
await settingsManager.set('rootFolder', value);
store.update((s) => {
s['rootFolder'] = value;
return s;
});
};
export default {
subscribe: store.subscribe,
setRootFolder
};
I thought that initializing the SettingsManager instance would make it so the key exists.
I worry this is a problem with my tauri app not being able to write to disk, but my tauri.conf.json has
"tauri": {
"allowlist": {
...
"fs": {
"all": true,
"scope": ["**", "$APPCONFIG", "$APPCONFIG/*"]
},
...
"path": {
"all": true
},
...
},
ERROR Failed to compile with 1 error 17:00:16
This relative module was not found:
* ../config/config in ./node_modules/tauri-settings/dist/fs/load-save.js
Followed install instructions as in readme.
main.js vue
const settingsManager = new SettingsManager({
"ip": "NOT-SET",
"theme": "dark"
});
Vue.prototype.$tauri.settings = settingsManager;
... new vue stuff
App.vue
const ipAddress = await $tauri.settings.get("ip");
This looks like a neat lib but I have a small question about configuration and extensibility.
How would you handle a config that was initially setup say for version 1.0.0
.
{
"theme": "light"
}
Then in version 2.0.0
you add a new config option say telemetry
. How would you expand the config to keep it backwards compatible?
I've seen something in zustand that solves this problem when persiting local storage by allowing versions numbers and migrations to exists. Would that besomething that should be added to this lib?
https://docs.pmnd.rs/zustand/integrations/persisting-store-data
Happy to hear thoughts on this as I'm actively considering switching to this for Overlayed.
When the settings directory doesn't exist and two settings files are used, the module tries to create the settings directory twice. The second time fails, and thus the second settings file can't be created.
The error message [Error] ERROR Error: Uncaught (in promise): path: /home/user/.config/com.program.name/ (non recursive): File exists (os error 17)
is shown when starting the program with the directory ~/.config.program.name/ not existing. If instead the directory exists (even if it is empty), both settings files are successfully created.
This bug lead to the application crashing because one of the two settings files is unavailable at the first run after deleting the settings directory.
There's 0 examples of using this in a JavaScript setting or even in a ReactJS app.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.