Skip to content

API reference > @kontsedal/olas-persist > createPersisted

createPersisted() function ​

Persist a signal-like source under key. Loads the stored value on construction (sync for localStorage, async for any storage that returns a promise). Subsequent writes to the source are mirrored to storage.

Cleanup (unsubscribe + cross-tab listener removal) is bound to ctx.

Signature:

typescript
export declare function createPersisted<T>(ctx: Ctx, key: string, source: PersistableSource<T>, options?: PersistOptions<T>): Persisted;

Parameters ​

Parameter

Type

Description

ctx

Ctx

key

string

source

PersistableSource<T>

options

PersistOptions<T>

(Optional)

Returns:

Persisted

Released under the MIT License.