Skip to main content
Version: v10.0.0

SyncOptions


Import
import { SyncOptions } from "@hyper-fetch/db"

Preview​

type SyncOptions<Row,KeyField,Listener,Type,Mapped> = {
byKey?: (key: NonNullable<Row[KeyField]>) => ListenerPatch;
incomplete?: refetch;
key?: (message: SyncMessage<Listener>) => NonNullable<Row[KeyField]>;
resumes?: boolean;
row?: (message: SyncMessage<Listener>) => Mapped;
type: Type;
where?: { [ Field in keyof Row & string]?: { eq: (value: Row[Field]) => ListenerPatch } };
}

Structure​

SyncOptions
NameTypeDescription
incomplete
refetch

Loads the row by key when an update arrives for a row the collection does not hold

resumes
boolean

The adapter resumes the subscription from its last event id after a reconnect, so nothing is missed

type
Type
where
{ [ Field in keyof Row & string]?: { eq: (value: Row[Field]) => ListenerPatch } }

Maps a query's filters to listener params or a subscription payload

byKey
(key: NonNullable<Row[KeyField]>) => ListenerPatch

Listener params that keep one row read by key live, such as a channel per record

key
(message: SyncMessage<Listener>) => NonNullable<Row[KeyField]>

Reads the key of a deleted row from a message

row
(message: SyncMessage<Listener>) => Mapped

Reshapes a message into a row, or into the key and changed fields for update