0.1.3 #4
@@ -52,9 +52,9 @@ export const useOptionalInput: {
|
|||||||
// Only mutate the internal state if the upstream value is actually different. This avoids infinite re-render loops.
|
// Only mutate the internal state if the upstream value is actually different. This avoids infinite re-render loops.
|
||||||
Stream.runForEach(Stream.changesWith(options.ref.changes, Equivalence.strict()), Option.match({
|
Stream.runForEach(Stream.changesWith(options.ref.changes, Equivalence.strict()), Option.match({
|
||||||
onSome: upstreamValue => Effect.whenEffect(
|
onSome: upstreamValue => Effect.whenEffect(
|
||||||
Effect.andThen(
|
Schema.encode(options.schema)(upstreamValue).pipe(
|
||||||
Schema.encode(options.schema)(upstreamValue),
|
Effect.andThen(encodedUpstreamValue => Ref.set(internalRef, encodedUpstreamValue)),
|
||||||
encodedUpstreamValue => Ref.set(internalRef, encodedUpstreamValue),
|
Effect.andThen(Ref.set(enabledRef, true)),
|
||||||
),
|
),
|
||||||
internalRef.pipe(
|
internalRef.pipe(
|
||||||
Effect.andThen(Schema.decode(options.schema)),
|
Effect.andThen(Schema.decode(options.schema)),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const useRefState: {
|
|||||||
const [reactStateValue, setReactStateValue] = React.useState(yield* useOnce(() => ref))
|
const [reactStateValue, setReactStateValue] = React.useState(yield* useOnce(() => ref))
|
||||||
|
|
||||||
yield* useFork(() => Stream.runForEach(
|
yield* useFork(() => Stream.runForEach(
|
||||||
Stream.drop(Stream.changesWith(ref.changes, Equivalence.strict()), 1),
|
Stream.changesWith(ref.changes, Equivalence.strict()),
|
||||||
v => Effect.sync(() => setReactStateValue(v)),
|
v => Effect.sync(() => setReactStateValue(v)),
|
||||||
), [ref])
|
), [ref])
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const useSubscribeRefs: {
|
|||||||
))
|
))
|
||||||
|
|
||||||
yield* useFork(() => pipe(
|
yield* useFork(() => pipe(
|
||||||
refs.map(ref => Stream.drop(Stream.changesWith(ref.changes, Equivalence.strict()), 1)),
|
refs.map(ref => Stream.changesWith(ref.changes, Equivalence.strict())),
|
||||||
streams => Stream.zipLatestAll(...streams),
|
streams => Stream.zipLatestAll(...streams),
|
||||||
Stream.runForEach(v =>
|
Stream.runForEach(v =>
|
||||||
Effect.sync(() => setReactStateValue(v))
|
Effect.sync(() => setReactStateValue(v))
|
||||||
|
|||||||
Reference in New Issue
Block a user