Skip to content

crelte / std/stores / Writable

Class: Writable<T>

A svelte store

Prefer import { writable } from 'svelte/store'; if you don't have specific needs

Type Parameters

T

T

Constructors

Constructor

ts
new Writable<T>(def): Writable<T>;

Creates a new Writable

Parameters

def

T

A default value

Returns

Writable<T>

Methods

get()

ts
get(): T;

Get the current value

Returns

T


notify()

ts
notify(): void;

calls all subscribers with the value

Returns

void


readclone()

ts
readclone<U>(this): Readclone<U>;

Type Parameters

U

U extends | string | number | boolean | Cloneable | null | undefined

Parameters

this

Writable<U>

Returns

Readclone<U>


readonly()

ts
readonly(): Readable<T>;

Returns

Readable<T>


set()

ts
set(inner): void;

Sets the value and calls all subscribers with the value

Parameters

inner

T

Returns

void


setSilent()

ts
setSilent(inner): void;

Sets the value without calling all subscribers

Parameters

inner

T

Returns

void


subscribe()

ts
subscribe(fn, invalidate?): () => void;

The function get's called once with the current value and then when the values changes

Note

This does not check for equality like svelte.

Parameters

fn

(val) => void

invalidate?

() => void

Returns

a function which should be called to unsubscribe

ts
(): void;
Returns

void