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