Fix
All checks were successful
Lint / lint (push) Successful in 17s

This commit is contained in:
Julien Valverdé
2025-04-30 22:52:38 +02:00
parent 3980c10747
commit dce81be269

View File

@@ -380,13 +380,10 @@ export abstract class ReffuseNamespace<R> {
useRef<A, E, R>( useRef<A, E, R>(
this: ReffuseNamespace<R>, this: ReffuseNamespace<R>,
initialValue: () => A | Effect.Effect<A, E, R>, initialValue: () => Effect.Effect<A, E, R>,
): SubscriptionRef.SubscriptionRef<A> { ): SubscriptionRef.SubscriptionRef<A> {
return this.useMemo( return this.useMemo(
() => pipe(initialValue(), () => Effect.flatMap(initialValue(), SubscriptionRef.make),
v => Effect.isEffect(v) ? v : Effect.succeed(v),
Effect.flatMap(SubscriptionRef.make),
),
[], [],
{ doNotReExecuteOnRuntimeOrContextChange: true }, // Do not recreate the ref when the context changes { doNotReExecuteOnRuntimeOrContextChange: true }, // Do not recreate the ref when the context changes
) )
@@ -396,7 +393,7 @@ export abstract class ReffuseNamespace<R> {
this: ReffuseNamespace<R>, this: ReffuseNamespace<R>,
value: A, value: A,
): SubscriptionRef.SubscriptionRef<A> { ): SubscriptionRef.SubscriptionRef<A> {
const ref = this.useRef(() => value) const ref = this.useRef(() => Effect.succeed(value))
this.useEffect(() => Ref.set(ref, value), [value], { doNotReExecuteOnRuntimeOrContextChange: true }) this.useEffect(() => Ref.set(ref, value), [value], { doNotReExecuteOnRuntimeOrContextChange: true })
return ref return ref
} }