MCPcopy Create free account
hub / github.com/TanStack/query / notify

Function notify

packages/query-devtools/src/createCacheSubscriptionRegistry.ts:47–58  ·  view source on GitHub ↗

* Updates every subscription whose `shouldUpdate` accepts the event. * @param cache - The cache to compute the values from. * @param event - The cache event. * @param schedule - Runs each update. Defaults to running it right away.

(
    cache: Accessor<TCache>,
    event: TEvent,
    schedule: (update: () => void) => void = (update) => update(),
  )

Source from the content-addressed store, hash-verified

45 * @param schedule - Runs each update. Defaults to running it right away.
46 */
47 function notify(
48 cache: Accessor<TCache>,
49 event: TEvent,
50 schedule: (update: () => void) => void = (update) => update(),
51 ) {
52 for (const [id, subscription] of subscriptions) {
53 if (!subscription.shouldUpdate(event)) continue
54 schedule(() => {
55 if (subscriptions.has(id)) subscription.update(cache)
56 })
57 }
58 }
59
60 return { register, notify }
61}

Callers 2

setFunction · 0.85

Calls 3

updateFunction · 0.85
scheduleFunction · 0.85
updateMethod · 0.80

Tested by 1

setFunction · 0.68