Cleanup
All checks were successful
Lint / lint (push) Successful in 10s

This commit is contained in:
Julien Valverdé
2025-01-22 03:21:31 +01:00
parent 22e5bbfcc2
commit 5a19b4a2ce

View File

@@ -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> {