Skip to content

@statesync/svelte


@statesync/svelte / SvelteStoreLike

Interface: SvelteStoreLike<State>

Defined in: svelte.ts:27

Minimal structural interface for a Svelte writable store.

We intentionally avoid importing svelte/store types so this adapter stays dependency-free (from Svelte) and can be used in any environment.

The real Svelte writable store implements:

  • set(value) -- replaces the store value entirely
  • update(updater) -- derives the next value from the current one
  • subscribe(callback) -- not needed for applying snapshots

Any object that satisfies this shape (e.g. a custom store wrapper) is accepted by createSvelteSnapshotApplier.

Example

ts
import { writable } from 'svelte/store';

interface AppState { count: number; name: string }
const myStore: SvelteStoreLike<AppState> = writable({ count: 0, name: '' });

Type Parameters

Type ParameterDescription
StateThe shape of the store value.

Methods

set()

ts
set(value): void;

Defined in: svelte.ts:33

Replaces the store value with the given value, triggering all subscribers.

Parameters

ParameterTypeDescription
valueStateThe new store value.

Returns

void


update()

ts
update(updater): void;

Defined in: svelte.ts:39

Derives the next store value from the current one using the provided updater function.

Parameters

ParameterTypeDescription
updater(current) => StateA pure function that receives the current value and returns the next value.

Returns

void

Released under the MIT License.