From 175cbaa704d5138c1a467021f74d7b218f2ad24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Wed, 22 Jan 2025 00:59:40 +0100 Subject: [PATCH] Cleanup --- packages/reffuse/src/Reffuse.ts | 55 +-------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/packages/reffuse/src/Reffuse.ts b/packages/reffuse/src/Reffuse.ts index 5ed64cf..011c9aa 100644 --- a/packages/reffuse/src/Reffuse.ts +++ b/packages/reffuse/src/Reffuse.ts @@ -1,4 +1,4 @@ -import { Context, Effect, ExecutionStrategy, Exit, Fiber, Option, 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" @@ -69,48 +69,6 @@ export class Reffuse { } - /** - * ⚠️ Scope closing on cleanup is currently broken when using React strict mode! ⚠️ - * - * Reffuse equivalent to `React.useMemo`. - * - * `useMemo` will only recompute the memoized value by running the given synchronous effect when one of the deps has changed. \ - * Trying to run an asynchronous effect will throw. - * - * Changes to the Reffuse runtime or context will recompute the value in addition to the deps. - * You can disable this behavior by setting `doNotReExecuteOnRuntimeOrContextChange` to `true` in `options`. - */ - // useMemo( - // effect: Effect.Effect, - // deps?: React.DependencyList, - // options?: RenderOptions & ScopeOptions, - // ): A { - // const runSync = this.useRunSync() - - // const [value, scope] = React.useMemo(() => Scope.make(options?.finalizerExecutionStrategy).pipe( - // Effect.flatMap(scope => - // Effect.provideService(effect, Scope.Scope, scope).pipe( - // Effect.map(value => [value, scope] as const) - // ) - // ), - - // runSync, - // ), [ - // ...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runSync], - // ...(deps ?? []), - // ]) - - // React.useEffect(() => { - // // console.log("effect", value, scope) - // return () => { - // // console.log("cleanup", value, scope) - // runSync(Scope.close(scope, Exit.void)) - // } - // }, [scope]) - - // return value - // } - /** * Reffuse equivalent to `React.useMemo`. * @@ -381,17 +339,6 @@ export class Reffuse { return [reactStateValue, setValue] } - - useStreamState(stream: Stream.Stream): Option.Option { - const [reactStateValue, setReactStateValue] = React.useState(Option.none()) - - this.useFork(Stream.runForEach(stream, v => Effect.sync(() => - setReactStateValue(Option.some(v)) - )), [stream]) - - return reactStateValue - } - }