tapedb/react
Generated from the public tapedb/react entry point’s TypeScript declarations. Signatures and comments are the API contract for this preview.
Functions
Section titled “Functions”useBroadcast
Section titled “useBroadcast”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;useLive
Section titled “useLive”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>;useLivePage
Section titled “useLivePage”Live pages: useLivePage(db.task.findPage({ orderBy, take: 50 })).
declare function useLivePage<R>(query: PageQuery<R>): LivePage<R>;usePresence
Section titled “usePresence”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[];Interfaces
Section titled “Interfaces”LivePage
Section titled “LivePage”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>;}