@reffuse/extension-query 0.1.5 #16

Merged
Thilawyn merged 347 commits from next into master 2025-06-01 05:28:47 +02:00
3 changed files with 8 additions and 10 deletions
Showing only changes of commit 5044887d90 - Show all commits

View File

@@ -47,7 +47,7 @@ export const QueryExtension = ReffuseExtension.make(() => ({
>( >(
this: ReffuseNamespace.ReffuseNamespace<R | QueryClient.TagClassShape<FallbackA, HandledE>>, this: ReffuseNamespace.ReffuseNamespace<R | QueryClient.TagClassShape<FallbackA, HandledE>>,
props: UseQueryProps<QK, QA, QE, QR>, props: UseQueryProps<QK, QA, QE, QR>,
): QueryRunner.QueryRunner<QK, QA | FallbackA, Exclude<QE, HandledE>, QR> { ): QueryRunner.QueryRunner<QK, QA | FallbackA, Exclude<QE, HandledE>> {
const runner = this.useMemo(() => QueryRunner.make({ const runner = this.useMemo(() => QueryRunner.make({
QueryClient: QueryClient.makeGenericTagClass<FallbackA, HandledE>(), QueryClient: QueryClient.makeGenericTagClass<FallbackA, HandledE>(),
key: props.key, key: props.key,

View File

@@ -1,14 +1,12 @@
import { BrowserStream } from "@effect/platform-browser" import { BrowserStream } from "@effect/platform-browser"
import * as AsyncData from "@typed/async-data" import * as AsyncData from "@typed/async-data"
import { type Cause, type Context, Effect, Fiber, identity, Option, Queue, Ref, type Scope, Stream, SubscriptionRef } from "effect" import { type Cause, Effect, Fiber, identity, Option, Queue, Ref, type Scope, Stream, SubscriptionRef } from "effect"
import type * as QueryClient from "./QueryClient.js" import type * as QueryClient from "./QueryClient.js"
import * as QueryProgress from "./QueryProgress.js" import * as QueryProgress from "./QueryProgress.js"
import { QueryState } from "./internal/index.js" import { QueryState } from "./internal/index.js"
export interface QueryRunner<K extends readonly unknown[], A, E, R> { export interface QueryRunner<K extends readonly unknown[], A, E> {
readonly context: Context.Context<R>
readonly latestKeyRef: SubscriptionRef.SubscriptionRef<Option.Option<K>> readonly latestKeyRef: SubscriptionRef.SubscriptionRef<Option.Option<K>>
readonly stateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>> readonly stateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly fiberRef: SubscriptionRef.SubscriptionRef<Option.Option<Fiber.RuntimeFiber< readonly fiberRef: SubscriptionRef.SubscriptionRef<Option.Option<Fiber.RuntimeFiber<
@@ -43,7 +41,7 @@ export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>
query, query,
}: MakeProps<K, A, FallbackA, E, HandledE, R> }: MakeProps<K, A, FallbackA, E, HandledE, R>
): Effect.Effect< ): Effect.Effect<
QueryRunner<K, A | FallbackA, Exclude<E, HandledE>, R>, QueryRunner<K, A | FallbackA, Exclude<E, HandledE>>,
never, never,
R | QueryClient.TagClassShape<FallbackA, HandledE> R | QueryClient.TagClassShape<FallbackA, HandledE>
> => Effect.gen(function*() { > => Effect.gen(function*() {
@@ -188,8 +186,8 @@ export interface RunOptions {
readonly refreshOnWindowFocus?: boolean readonly refreshOnWindowFocus?: boolean
} }
export const run = <K extends readonly unknown[], A, E, R>( export const run = <K extends readonly unknown[], A, E>(
self: QueryRunner<K, A, E, R>, self: QueryRunner<K, A, E>,
options?: RunOptions, options?: RunOptions,
): Effect.Effect<void, Error | Cause.NoSuchElementException, Scope.Scope> => Effect.gen(function*() { ): Effect.Effect<void, Error | Cause.NoSuchElementException, Scope.Scope> => Effect.gen(function*() {
if (typeof window !== "undefined" && (options?.refreshOnWindowFocus ?? true)) if (typeof window !== "undefined" && (options?.refreshOnWindowFocus ?? true))

View File

@@ -13,5 +13,5 @@ export interface QueryService<K extends readonly unknown[], A, E> {
} }
export const Tag = <const Id extends string>(id: Id) => < export const Tag = <const Id extends string>(id: Id) => <
Self, K extends readonly unknown[], A, E = never, R = never, Self, K extends readonly unknown[], A, E = never
>() => Effect.Tag(id)<Self, QueryRunner.QueryRunner<K, A, E, R>>() >() => Effect.Tag(id)<Self, QueryRunner.QueryRunner<K, A, E>>()