MCPcopy Create free account
hub / github.com/Effect-TS/effect / prefetch

Function prefetch

packages/effect/src/ui/Query.ts:6548–6571  ·  view source on GitHub ↗
(def, args, fetcher, awaited)

Source from the content-addressed store, hash-verified

6546 })
6547
6548 const prefetch: CacheInternals["prefetch"] = (def, args, fetcher, awaited) => {
6549 if (disposed) return undefined
6550 const entry = ensureEntry(register(def), args)
6551 // Nothing under a live patch.
6552 if (hasLive(entry)) return undefined
6553 // A list that holds pages, stale ones included, isn't loaded again.
6554 if (
6555 inWindow(entry) || !isStale(entry) ||
6556 (entry.def.list !== undefined &&
6557 entry.def.list.ops.heldPages(entry).length > 0)
6558 ) {
6559 resetIdle(entry)
6560 return undefined
6561 }
6562 if (entry.fetch !== undefined) entry.kept = true
6563 // A stream query's idle deadline runs while its stream opens, so it counts from the latest request.
6564 resetIdle(entry)
6565 ensureFetch(entry, "prefetch", buildOf(fetcher))
6566 afterQuiet(entry)
6567 if (awaited !== true || !owesRefetch(entry)) return undefined
6568 let quiet = prefetchAwaits.get(entry)
6569 if (quiet === undefined) prefetchAwaits.set(entry, quiet = Deferred.makeUnsafe())
6570 return Deferred.await(quiet)
6571 }
6572
6573 const loadMore: CacheInternals["loadMore"] = (
6574 def,

Callers

nothing calls this directly

Calls 13

ensureEntryFunction · 0.85
hasLiveFunction · 0.85
resetIdleFunction · 0.85
ensureFetchFunction · 0.85
buildOfFunction · 0.85
afterQuietFunction · 0.85
owesRefetchFunction · 0.85
registerFunction · 0.70
inWindowFunction · 0.70
isStaleFunction · 0.70
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected