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

Function notify

packages/query-devtools/src/createCacheSubscriptionRegistry.ts:48–59  ·  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, receiving the subscription's id so repeated updates of the * same subscription can be merged

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

Source from the content-addressed store, hash-verified

46 * same subscription can be merged.
47 */
48 function notify(
49 cache: Accessor<TCache>,
50 event: TEvent,
51 schedule: (update: () => void, id: symbol) => void,
52 ) {
53 for (const [id, subscription] of subscriptions) {
54 if (!subscription.shouldUpdate(event)) continue
55 schedule(() => {
56 if (subscriptions.has(id)) subscription.update(cache)
57 }, id)
58 }
59 }
60
61 return { register, notify }
62}

Callers 2

setFunction · 0.85

Calls 3

scheduleFunction · 0.85
hasMethod · 0.80
updateMethod · 0.80

Tested by 1

setFunction · 0.68