MCPcopy Create free account
hub / github.com/effect-app/libs / useScopedSuspenseSetup

Function useScopedSuspenseSetup

packages/vue/src/makeClient.ts:35–56  ·  view source on GitHub ↗
(setup: () => A)

Source from the content-addressed store, hash-verified

33export type { Progress }
34
35const useScopedSuspenseSetup = <A>(setup: () => A) => {
36 const scope = effectScope()
37 const controller = new AbortController()
38 const value = scope.run(setup)
39 if (value === undefined) {
40 throw new Error("Internal Error: suspense setup scope did not initialize")
41 }
42
43 const isMounted = ref(true)
44 let stopped = false
45 const stop = () => {
46 if (stopped) return
47 stopped = true
48 isMounted.value = false
49 controller.abort()
50 scope.stop()
51 }
52 onBeforeUnmount(stop)
53 onScopeDispose(stop)
54
55 return [value, isMounted, controller.signal] as const
56}
57
58/**
59 * A suspense query settled with an interrupt-only cause while its component was still MOUNTED.

Callers 1

QueryImplClass · 0.70

Calls 1

runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…