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