0.1.11 #14
@@ -18,20 +18,6 @@ export function VQueryErrorHandler() {
|
|||||||
), [])
|
), [])
|
||||||
)
|
)
|
||||||
|
|
||||||
const error2 = R.useSubscribeStream(
|
|
||||||
R.useMemo(() => AppQueryErrorHandler.pipe(
|
|
||||||
Effect.flatMap()
|
|
||||||
|
|
||||||
Effect.map(handler => handler.errors.pipe(
|
|
||||||
Stream.changes,
|
|
||||||
Stream.tap(Console.error),
|
|
||||||
Stream.tap(() => Effect.sync(() => setOpen(true))),
|
|
||||||
))
|
|
||||||
), []),
|
|
||||||
|
|
||||||
() => Effect.fail(new Error()),
|
|
||||||
)
|
|
||||||
|
|
||||||
if (Option.isNone(error))
|
if (Option.isNone(error))
|
||||||
return <></>
|
return <></>
|
||||||
|
|
||||||
|
|||||||
@@ -487,15 +487,15 @@ export abstract class ReffuseNamespace<R> {
|
|||||||
this: ReffuseNamespace<R>,
|
this: ReffuseNamespace<R>,
|
||||||
stream: Stream.Stream<A, E, R>,
|
stream: Stream.Stream<A, E, R>,
|
||||||
): Option.Option<A>
|
): Option.Option<A>
|
||||||
useSubscribeStream<A, E, R>(
|
useSubscribeStream<A, E, IE, R>(
|
||||||
this: ReffuseNamespace<R>,
|
this: ReffuseNamespace<R>,
|
||||||
stream: Stream.Stream<A, E, R>,
|
stream: Stream.Stream<A, E, R>,
|
||||||
initialValue: () => Effect.Effect<A, E, R>,
|
initialValue: () => Effect.Effect<A, IE, R>,
|
||||||
): Option.Some<A>
|
): Option.Some<A>
|
||||||
useSubscribeStream<A, E, R>(
|
useSubscribeStream<A, E, IE, R>(
|
||||||
this: ReffuseNamespace<R>,
|
this: ReffuseNamespace<R>,
|
||||||
stream: Stream.Stream<A, E, R>,
|
stream: Stream.Stream<A, E, R>,
|
||||||
initialValue?: () => Effect.Effect<A, E, R>,
|
initialValue?: () => Effect.Effect<A, IE, R>,
|
||||||
): Option.Option<A> {
|
): Option.Option<A> {
|
||||||
const [reactStateValue, setReactStateValue] = React.useState(this.useMemo(
|
const [reactStateValue, setReactStateValue] = React.useState(this.useMemo(
|
||||||
() => initialValue
|
() => initialValue
|
||||||
@@ -513,19 +513,25 @@ export abstract class ReffuseNamespace<R> {
|
|||||||
return reactStateValue
|
return reactStateValue
|
||||||
}
|
}
|
||||||
|
|
||||||
usePullStream<A, InitialA extends A | undefined, E, InitialE, R>(
|
usePullStream<A, E, IE, R>(
|
||||||
this: ReffuseNamespace<R>,
|
this: ReffuseNamespace<R>,
|
||||||
stream: Stream.Stream<A, E, R>,
|
stream: Stream.Stream<A, E, R>,
|
||||||
initialValue?: () => Effect.Effect<InitialA, InitialE, R>,
|
): [latestValue: Option.Option<A>, pull: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>>]
|
||||||
): [
|
usePullStream<A, E, IE, R>(
|
||||||
latestValue: InitialA extends A ? Option.Some<A> : Option.Option<A>,
|
this: ReffuseNamespace<R>,
|
||||||
pull: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>>,
|
stream: Stream.Stream<A, E, R>,
|
||||||
] {
|
initialValue: () => Effect.Effect<A, IE, R>,
|
||||||
|
): [latestValue: Option.Some<A>, pull: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>>]
|
||||||
|
usePullStream<A, E, IE, R>(
|
||||||
|
this: ReffuseNamespace<R>,
|
||||||
|
stream: Stream.Stream<A, E, R>,
|
||||||
|
initialValue?: () => Effect.Effect<A, IE, R>,
|
||||||
|
): [latestValue: Option.Option<A>, pull: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>>] {
|
||||||
const scope = this.useScope([stream])
|
const scope = this.useScope([stream])
|
||||||
|
|
||||||
const [reactStateValue, setReactStateValue] = React.useState<Option.Option<A>>(this.useMemo(
|
const [reactStateValue, setReactStateValue] = React.useState(this.useMemo(
|
||||||
() => initialValue
|
() => initialValue
|
||||||
? Effect.map(initialValue(), v => Option.some(v as A))
|
? Effect.map(initialValue(), Option.some)
|
||||||
: Effect.succeed(Option.none()),
|
: Effect.succeed(Option.none()),
|
||||||
[],
|
[],
|
||||||
{ doNotReExecuteOnRuntimeOrContextChange: true },
|
{ doNotReExecuteOnRuntimeOrContextChange: true },
|
||||||
@@ -548,10 +554,7 @@ export abstract class ReffuseNamespace<R> {
|
|||||||
))
|
))
|
||||||
), [stream, scope])
|
), [stream, scope])
|
||||||
|
|
||||||
return [
|
return [reactStateValue, pull]
|
||||||
reactStateValue as InitialA extends A ? Option.Some<A> : Option.Option<A>,
|
|
||||||
pull,
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user