Giter VIP home page Giter VIP logo

tauri-settings's Introduction

tauri-settings's People

Contributors

dependabot[bot] avatar feored avatar harshkhandeparkar avatar kingcodefish avatar mrkpatchaa avatar newclarityex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tauri-settings's Issues

Unhandled Promise Rejection: Error: key does not exist

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
			},
			...
		},

Relative module not found.

 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");

Settings directory is created twice if two settings files are used

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.

Versioned configs

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.

JavaScript Examples

There's 0 examples of using this in a JavaScript setting or even in a ReactJS app.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.