@@ -1,4 +1,4 @@
|
||||
import { Context, Effect, Exit, Fiber, Ref, Runtime, Scope, Stream, SubscriptionRef } from "effect"
|
||||
import { Context, Effect, ExecutionStrategy, Exit, Fiber, Ref, Runtime, Scope, Stream, SubscriptionRef } from "effect"
|
||||
import React from "react"
|
||||
import * as ReffuseContext from "./ReffuseContext.js"
|
||||
import * as ReffuseRuntime from "./ReffuseRuntime.js"
|
||||
@@ -71,12 +71,12 @@ export class Reffuse<R> {
|
||||
useEffect<A, E>(
|
||||
effect: Effect.Effect<A, E, R | Scope.Scope>,
|
||||
deps?: React.DependencyList,
|
||||
options?: RenderOptions,
|
||||
options?: RenderOptions & ScopeOptions,
|
||||
): void {
|
||||
const runSync = this.useRunSync()
|
||||
|
||||
return React.useEffect(() => {
|
||||
const scope = Scope.make().pipe(
|
||||
const scope = Scope.make(options?.finalizerExecutionStrategy).pipe(
|
||||
Effect.tap(scope => Effect.provideService(effect, Scope.Scope, scope)),
|
||||
runSync,
|
||||
)
|
||||
@@ -158,6 +158,10 @@ export interface RenderOptions {
|
||||
readonly doNotReExecuteOnRuntimeOrContextChange?: boolean
|
||||
}
|
||||
|
||||
export interface ScopeOptions {
|
||||
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy
|
||||
}
|
||||
|
||||
|
||||
export const make = <
|
||||
const Contexts extends readonly ReffuseContext.ReffuseContext<any>[]
|
||||
|
||||
Reference in New Issue
Block a user