This commit is contained in:
@@ -299,29 +299,29 @@ export class Reffuse<R> {
|
|||||||
// return React.use(promise)
|
// return React.use(promise)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
useSuspenseScoped<A, E>(
|
// useSuspenseScoped<A, E>(
|
||||||
effect: Effect.Effect<A, E, R | Scope.Scope>,
|
// effect: Effect.Effect<A, E, R | Scope.Scope>,
|
||||||
deps?: React.DependencyList,
|
// deps?: React.DependencyList,
|
||||||
options?: { readonly signal?: AbortSignal } & RenderOptions & ScopeOptions,
|
// options?: { readonly signal?: AbortSignal } & RenderOptions & ScopeOptions,
|
||||||
): A {
|
// ): A {
|
||||||
const runSync = this.useRunSync()
|
// const runSync = this.useRunSync()
|
||||||
const runPromise = this.useRunPromise()
|
// const runPromise = this.useRunPromise()
|
||||||
|
|
||||||
const initialPromise = React.useMemo(() => runPromise(Effect.scoped(effect)), [])
|
// const initialPromise = React.useMemo(() => runPromise(Effect.scoped(effect)), [])
|
||||||
const [promise, setPromise] = React.useState(initialPromise)
|
// const [promise, setPromise] = React.useState(initialPromise)
|
||||||
|
|
||||||
React.useEffect(() => {
|
// React.useEffect(() => {
|
||||||
const scope = runSync(Scope.make())
|
// const scope = runSync(Scope.make())
|
||||||
setPromise(runPromise(Effect.provideService(effect, Scope.Scope, scope), options))
|
// setPromise(runPromise(Effect.provideService(effect, Scope.Scope, scope), options))
|
||||||
|
|
||||||
return () => { runPromise(Scope.close(scope, Exit.void)) }
|
// return () => { runPromise(Scope.close(scope, Exit.void)) }
|
||||||
}, [
|
// }, [
|
||||||
...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runSync, runPromise],
|
// ...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runSync, runPromise],
|
||||||
...(deps ?? []),
|
// ...(deps ?? []),
|
||||||
])
|
// ])
|
||||||
|
|
||||||
return React.use(promise)
|
// return React.use(promise)
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
useRef<A>(value: A): SubscriptionRef.SubscriptionRef<A> {
|
useRef<A>(value: A): SubscriptionRef.SubscriptionRef<A> {
|
||||||
|
|||||||
Reference in New Issue
Block a user