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

Function closeWindow

packages/effect/src/ui/Query.ts:7118–7186  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7116 }
7117 }
7118 const closeWindow = (): void => {
7119 adopting = false
7120 // An entry made while the page was adopted gets its saved value now: as its
7121 // result, or under a Failure that has no previous Success.
7122 for (const entry of unrestored) {
7123 const result = entry.result
7124 if (
7125 entry.removed || result?._tag === "Success" ||
7126 (result !== undefined && Option.isSome(result.previousSuccess))
7127 ) continue
7128 const saved = savedOf(entry.def, entry.argsKey)
7129 if (saved === undefined) continue
7130 if (result === undefined) {
7131 entry.result = saved
7132 entry.settledAt = now()
7133 entry.invalidated = true
7134 } else {
7135 entry.result = AsyncResult.failure(result.cause, {
7136 previousSuccess: Option.some(saved)
7137 })
7138 }
7139 emit(entry)
7140 }
7141 unrestored.clear()
7142 if (!windowOpen) return
7143 windowOpen = false
7144 for (const [name, byKey] of raw) {
7145 for (const [argsKey, tuple] of byKey) {
7146 if (tuple[1] === 1) byKey.delete(argsKey)
7147 }
7148 if (byKey.size === 0) raw.delete(name)
7149 }
7150 for (const entry of allEntries()) {
7151 if (!entry.hydrated) continue
7152 entry.hydrated = false
7153 if (entry.watchers.size === 0 && isBareFailure(entry.result)) {
7154 entry.result = undefined
7155 afterQuiet(entry)
7156 }
7157 // A watched stream query opens its stream, which the window held back.
7158 if (entry.def.live !== undefined) {
7159 const build = survivingBuild(entry)
7160 if (build !== undefined) {
7161 let path: string | undefined
7162 for (const watcher of entry.watchers) {
7163 if (watcher.build === build) {
7164 path = watcher.path
7165 break
7166 }
7167 }
7168 ensureFetch(entry, "watch", build, undefined, path)
7169 }
7170 }
7171 if (
7172 entry.def.list !== undefined && entry.fetch === undefined &&
7173 !hasLive(entry)
7174 ) {
7175 const deferredWatcher = entry.deferredWatcher

Callers

nothing calls this directly

Calls 13

savedOfFunction · 0.85
allEntriesFunction · 0.85
isBareFailureFunction · 0.85
afterQuietFunction · 0.85
survivingBuildFunction · 0.85
ensureFetchFunction · 0.85
hasLiveFunction · 0.85
cacheEnvFunction · 0.85
someMethod · 0.80
nowFunction · 0.70
emitFunction · 0.70
clearMethod · 0.65

Tested by

no test coverage detected