0.1.8 #11

Merged
Thilawyn merged 233 commits from next into master 2025-04-21 02:08:14 +02:00
Showing only changes of commit f4ab575a8d - Show all commits

View File

@@ -2,17 +2,11 @@ import type * as AsyncData from "@typed/async-data"
import { type Cause, type Context, Effect, type Fiber, Layer, type Option, type Stream, type SubscriptionRef } from "effect" import { type Cause, type Context, Effect, type Fiber, Layer, type Option, type Stream, type SubscriptionRef } from "effect"
import * as React from "react" import * as React from "react"
import { ReffuseExtension, type ReffuseHelpers } from "reffuse" import { ReffuseExtension, type ReffuseHelpers } from "reffuse"
import type * as QueryClient from "./QueryClient.js"
import * as QueryRunner from "./QueryRunner.js" import * as QueryRunner from "./QueryRunner.js"
import type * as QueryService from "./QueryService.js" import type * as QueryService from "./QueryService.js"
export interface QueryExtension<HandlerE> {
useQuery<K extends readonly unknown[], A, E, R>(
this: ReffuseHelpers.ReffuseHelpers<R>,
props: UseQueryProps<K, A, E, R>,
): UseQueryResult<K, A, Exclude<E, HandlerE>>
}
export interface UseQueryProps<K extends readonly unknown[], A, E, R> { export interface UseQueryProps<K extends readonly unknown[], A, E, R> {
readonly key: Stream.Stream<K> readonly key: Stream.Stream<K>
readonly query: (key: K) => Effect.Effect<A, E, R> readonly query: (key: K) => Effect.Effect<A, E, R>
@@ -31,10 +25,10 @@ export interface UseQueryResult<K extends readonly unknown[], A, E> {
export const QueryExtension = ReffuseExtension.make(() => ({ export const QueryExtension = ReffuseExtension.make(() => ({
useQuery<K extends readonly unknown[], A, E, R>( useQuery<EH, K extends readonly unknown[], A, E, HandledE, R>(
this: ReffuseHelpers.ReffuseHelpers<R>, this: ReffuseHelpers.ReffuseHelpers<R | QueryClient.QueryClient<EH, HandledE>>,
props: UseQueryProps<K, A, E, R>, props: UseQueryProps<K, A, E, R>,
): UseQueryResult<K, A, E> { ): UseQueryResult<K, A, Exclude<E, HandledE>> {
const runner = this.useMemo(() => QueryRunner.make({ const runner = this.useMemo(() => QueryRunner.make({
key: props.key, key: props.key,
query: props.query, query: props.query,