本页还没有译文
本页 73 段还没译成简体中文,下面显示的是英文原文。SubscribeChangesOptions
还没翻译译自英文(tanstack.com)本页 73 段都还没译
Defined in: packages/db/src/types.ts:1073
Options for subscribing to collection changes
Type Parameters
T
T extends object = Record<string, unknown>
TKey
TKey extends string | number = string | number
Properties
deferAcquisition?
optional deferAcquisition: boolean;Defined in: packages/db/src/types.ts:1104
Internal
Whether this subscription defers provider work. It keeps the Collection
alive and reads its local rows, but starts no idle source sync run and no
acquisition attempt until subscription.resumeDeferredAcquisition(). A
live-query Collection defers its source subscriptions until it has a
subscriber or a preload in its current sync run.
includeInitialState?
optional includeInitialState: boolean;Defined in: packages/db/src/types.ts:1078
Whether to include the current state as initial changes
limit?
optional limit: number;Defined in: packages/db/src/types.ts:1120
Internal
Optional limit to include in loadSubset for query-specific cache keys.
onLoadSubsetError()?
optional onLoadSubsetError: (event) => void;Defined in: packages/db/src/types.ts:1128
Internal
Receives subset-load failures scoped to this subscription.
Parameters
event
SubscriptionLoadSubsetErrorEvent
Returns
void
onLoadSubsetResult()?
optional onLoadSubsetResult: (result) => void;Defined in: packages/db/src/types.ts:1126
Internal
Callback that receives the loadSubset result (Promise or true) from requestSnapshot. Allows the caller to directly track the loading promise for isReady status.
Parameters
result
Returns
void
onStatusChange()?
optional onStatusChange: (event) => void;Defined in: packages/db/src/types.ts:1110
Internal
Listener for subscription status changes. Registered BEFORE any snapshot is requested, ensuring no status transitions are missed.
Parameters
event
Returns
void
orderBy?
optional orderBy: OrderBy;Defined in: packages/db/src/types.ts:1115
Internal
Optional orderBy to include in loadSubset for query-specific cache keys.
truncateReplayPublication?
optional truncateReplayPublication: object;Defined in: packages/db/src/types.ts:1130
Internal
Lets a live-query graph retain its last publication during replay.
start()
readonly start: () => void;Returns
void
succeed()
readonly succeed: () => void;Returns
void
where()?
optional where: (row) => any;Defined in: packages/db/src/types.ts:1093
Callback function for filtering changes using a row proxy.
The callback receives a proxy object that records property access,
allowing you to use query builder functions like eq, gt, etc.
Parameters
row
SingleRowRefProxy<WithVirtualProps<T, TKey>, TKey, true>
Returns
any
Example
import { eq } from "@tanstack/db"
collection.subscribeChanges(callback, {
where: (row) => eq(row.status, "active")
})whereExpression?
optional whereExpression: BasicExpression<boolean>;Defined in: packages/db/src/types.ts:1095
Pre-compiled expression for filtering changes