0.1.0 #1

Merged
Thilawyn merged 87 commits from next into master 2025-01-18 00:54:42 +01:00
Showing only changes of commit 4d411bc8dc - Show all commits

View File

@@ -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 ?? []),
])
}