| 33 | export type { Progress } |
| 34 | |
| 35 | const 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. |