@tauri-store/svelte - v2.1.1
    Preparing search index...

    Class Store<S>

    A writable store that can sync its state with the Rust backend and persist it to disk. It adheres to the Svelte store contract, so it's interchangeable with conventional Svelte stores.

    If you prefer runes, use the RuneStore class instead.

    import { Store } from '@tauri-store/svelte';

    const store = new Store('counter', { count: 0 });

    // Start the store, allowing it to sync with the backend.
    await store.start();

    store.subscribe((state) => {
    console.log(state.count);
    });

    store.set({ count: 2 });

    store.update((state) => {
    state.count += 1;
    });

    // Save the store to disk.
    await store.save();

    Type Parameters

    Hierarchy

    • BaseStore<S>
      • Store

    Implements

    Index

    Constructors

    Properties

    id: string

    Methods

    • Starts the store synchronization.

      Returns Promise<void>

    • Stops the store synchronization.

      Returns Promise<void>

    • Subscribe on value changes.

      Parameters

      • run: Subscriber<S>

        subscription callback

      • Optionalinvalidate: () => void

        cleanup callback

      Returns Unsubscriber

    • Update value using callback and inform subscribers.

      Parameters

      • updater: Updater<S>

        callback

      Returns void