MCPcopy Create free account
hub / github.com/TanStack/db / schedule

Method schedule

packages/db/src/collection/cleanup-queue.ts:30–41  ·  view source on GitHub ↗

* Queues a cleanup task and defers timeout selection to a microtask so * multiple synchronous registrations can share one root timer.

(key: unknown, gcTime: number, callback: () => void)

Source from the content-addressed store, hash-verified

28 * multiple synchronous registrations can share one root timer.
29 */
30 public schedule(key: unknown, gcTime: number, callback: () => void): void {
31 const executeAt = Date.now() + gcTime
32 this.tasks.set(key, { executeAt, callback })
33
34 if (!this.microtaskScheduled) {
35 this.microtaskScheduled = true
36 Promise.resolve().then(() => {
37 this.microtaskScheduled = false
38 this.updateTimeout()
39 })
40 }
41 }
42
43 public cancel(key: unknown): void {
44 this.tasks.delete(key)

Callers 3

startGCTimerMethod · 0.45
scheduleGraphRunMethod · 0.45
scheduleGraphRunMethod · 0.45

Calls 2

updateTimeoutMethod · 0.95
setMethod · 0.45

Tested by

no test coverage detected