@reffuse/extension-query 0.1.4 #15
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user