0.1.13 #18

Merged
Thilawyn merged 359 commits from next into master 2025-06-18 00:12:19 +02:00
Showing only changes of commit 3548ed5718 - Show all commits

View File

@@ -61,26 +61,22 @@ export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>
const queryStateTag = QueryState.makeTag<A | FallbackA, Exclude<E, HandledE>>() const queryStateTag = QueryState.makeTag<A | FallbackA, Exclude<E, HandledE>>()
const interrupt = fiberRef.pipe( const interrupt = Effect.flatMap(fiberRef, Option.match({
Effect.flatMap(Option.match({ onSome: fiber => Ref.set(fiberRef, Option.none()).pipe(
onSome: fiber => Ref.set(fiberRef, Option.none()).pipe( Effect.andThen(Fiber.interrupt(fiber))
Effect.andThen(Fiber.interrupt(fiber)) ),
), onNone: () => Effect.void,
onNone: () => Effect.void, }))
}))
)
const forkInterrupt = fiberRef.pipe( const forkInterrupt = Effect.flatMap(fiberRef, Option.match({
Effect.flatMap(Option.match({ onSome: fiber => Ref.set(fiberRef, Option.none()).pipe(
onSome: fiber => Ref.set(fiberRef, Option.none()).pipe( Effect.andThen(Fiber.interrupt(fiber).pipe(
Effect.andThen(Fiber.interrupt(fiber).pipe( Effect.asVoid,
Effect.asVoid, Effect.forkDaemon,
Effect.forkDaemon, ))
)) ),
), onNone: () => Effect.forkDaemon(Effect.void),
onNone: () => Effect.forkDaemon(Effect.void), }))
}))
)
const run = Effect.Do.pipe( const run = Effect.Do.pipe(
Effect.bind("state", () => queryStateTag), Effect.bind("state", () => queryStateTag),
@@ -129,15 +125,13 @@ export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>
)) ))
) )
const setInitialRefreshState = queryStateTag.pipe( const setInitialRefreshState = Effect.flatMap(queryStateTag, state => state.update(previous => {
Effect.flatMap(state => state.update(previous => { if (AsyncData.isSuccess(previous) || AsyncData.isFailure(previous))
if (AsyncData.isSuccess(previous) || AsyncData.isFailure(previous)) return AsyncData.refreshing(previous)
return AsyncData.refreshing(previous) if (AsyncData.isRefreshing(previous))
if (AsyncData.isRefreshing(previous)) return AsyncData.refreshing(previous.previous)
return AsyncData.refreshing(previous.previous) return AsyncData.loading()
return AsyncData.loading() }))
}))
)
const forkRefresh = Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>().pipe( const forkRefresh = Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>().pipe(
Effect.flatMap(stateQueue => interrupt.pipe( Effect.flatMap(stateQueue => interrupt.pipe(