Skip to content

Storage

Bindings for @solid-primitives/storage.

SyncStorage

Type: interface

  • getItem: key: string -> string option
  • setItem: key: string * value: string -> unit
  • removeItem: key: string -> unit

AsyncStorage

Type: interface

  • getItem: key: string -> Promise<string option>
  • setItem: key: string * value: string -> Promise<obj>
  • removeItem: key: string -> Promise<unit>

SyncStorageWithOptions

Type: interface

Type parameter: 'Options

  • getItem: key: string * ?options: 'Options -> string option
  • setItem: key: string * value: string * ?options: 'Options -> unit
  • removeItem: key: string * ?options: 'Options -> unit

AsyncStorageWithOptions

Type: interface

Type parameter: 'Options

  • getItem: key: string * ?options: 'Options -> Promise<string option>
  • setItem: key: string * value: string * ?options: 'Options -> Promise<obj>
  • removeItem: key: string * ?options: 'Options -> Promise<unit>

PersistenceSyncData

Type: interface

  • key: string
  • newValue: string option
  • timeStamp: float
  • url: string option

PersistenceSyncCallback

PersistenceSyncData -> unit

PersistenceSyncSubscribe

PersistenceSyncCallback -> unit

PersistenceSyncUpdate

key: string * value: string option -> unit

PersistenceSyncAPI

PersistenceSyncSubscribe * PersistenceSyncUpdate

PersistenceOptions

Type: POJO

Type parameters: 'T, 'Options

  • name: string
  • serialize: 'T -> string
  • deserialize: string -> 'T
  • sync: PersistenceSyncAPI
  • storage: one of the four storages above, as a U4
  • storageOptions: 'Options

PersistedState

Type parameter: 'T

Accessor<'T> * Setter<'T> * obj

makePersisted takes a signal, such as the result of createSignal, and returns it with its value persisted.

Bindings

Bindings
[<Erase; AutoOpen>]
type Storage =
    [<ImportMember(Spec.path)>]
    static member makePersisted<'T>(signal: Signal<'T>, ?options: PersistenceOptions<'T, _>): PersistedState<'T> = jsNative
    [<ImportMember(Spec.path)>]
    static member storageSync: PersistenceSyncAPI = jsNative
    // TODO broadcast channel overload
    [<ImportMember(Spec.path)>]
    static member messageSync(?channel: Browser.Types.Window): PersistenceSyncAPI = jsNative
    // TODO
    // [<ImportMember(Spec.path)>]
    // static member wsSync(ws: WebSocket, ?warnOnError: bool): PersistenceSyncAPI = jsNative
    [<ImportMember(Spec.path)>]
    static member multiplexSync([<ParamArray>] syncAPIs: PersistenceSyncAPI[]): PersistenceSyncAPI = jsNative

messageSync has no BroadcastChannel overload yet, and wsSync is not bound.

Edit this page