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

Method once

packages/db/src/event-emitter.ts:37–46  ·  view source on GitHub ↗

* Subscribe to an event once (automatically unsubscribes after first emission) * @param event - Event name to listen for * @param callback - Function to call when event is emitted * @returns Unsubscribe function

(
    event: T,
    callback: (event: TEvents[T]) => void,
  )

Source from the content-addressed store, hash-verified

35 * @returns Unsubscribe function
36 */
37 once<T extends keyof TEvents>(
38 event: T,
39 callback: (event: TEvents[T]) => void,
40 ): () => void {
41 const unsubscribe = this.on(event, (eventPayload) => {
42 callback(eventPayload)
43 unsubscribe()
44 })
45 return unsubscribe
46 }
47
48 /**
49 * Unsubscribe from an event

Callers 6

getAvailablePortFunction · 0.45
constructorMethod · 0.45
startMethod · 0.45
stopWranglerProcessFunction · 0.45

Calls 1

onMethod · 0.95

Tested by 1

stopWranglerProcessFunction · 0.36