This commit is contained in:
@@ -119,15 +119,23 @@ export class Reffuse<R> {
|
||||
useFork<A, E>(
|
||||
effect: Effect.Effect<A, E, R | Scope.Scope>,
|
||||
deps?: React.DependencyList,
|
||||
options?: Runtime.RunForkOptions & RenderOptions,
|
||||
options?: Runtime.RunForkOptions & RenderOptions & ScopeOptions,
|
||||
): void {
|
||||
const runSync = this.useRunSync()
|
||||
const runFork = this.useRunFork()
|
||||
|
||||
return React.useEffect(() => {
|
||||
const fiber = runFork(Effect.scoped(effect), options)
|
||||
return () => { runFork(Fiber.interrupt(fiber)) }
|
||||
const scope = runSync(Scope.make(options?.finalizerExecutionStrategy))
|
||||
const fiber = runFork(Effect.provideService(effect, Scope.Scope, scope), options)
|
||||
|
||||
return () => {
|
||||
Fiber.interrupt(fiber).pipe(
|
||||
Effect.flatMap(() => Scope.close(scope, Exit.void)),
|
||||
runFork,
|
||||
)
|
||||
}
|
||||
}, [
|
||||
...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runFork],
|
||||
...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runSync, runFork],
|
||||
...(deps ?? []),
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user