Zum Inhalt springen

tapedb/react

Generiert aus den TypeScript-Deklarationen des öffentlichen tapedb/react-Entry-Points. Signaturen und Kommentare sind der API-Vertrag dieser Preview.

Listens on a broadcast topic while mounted and returns its send. The latest onMessage is always the one called, so it need not be memoised.

declare function useBroadcast<T = unknown>(db: {
$broadcast<M>(topic: string): BroadcastTopic<M>;
}, topic: string, onMessage?: (message: T, from: TopicSender) => void): (message: T) => boolean;

Live results for a query: useLive(db.task.findMany({ where })).

A new query object every render is fine: the subscription follows the query’s key, not its identity, so equal arguments keep one subscription.

declare function useLive<T>(query: Query<T>): LiveState<T>;

Live pages: useLivePage(db.task.findPage({ orderBy, take: 50 })).

declare function useLivePage<R>(query: PageQuery<R>): LivePage<R>;

Joins a presence room with presence and returns the other peers. Leaves the room on unmount; publishes again whenever presence changes.

declare function usePresence(db: {
$presence(room: string): PresenceRoom;
}, room: string, presence?: unknown): PresencePeer[];
interface LivePage<R> {
rows: R[];
hasMore: boolean;
isLoading: boolean;
error: LiveState<Page<R>>["error"];
/** Appends the next page; every loaded page stays live. */
loadMore(): Promise<boolean>;
}