(_getRuntime: () => Context.Context<R>, getAtomRt: () => AtomClientRuntime)
| 588 | const refetch = () => |
| 589 | Effect.gen(function*() { |
| 590 | yield* refreshAtomWithCurrentSpan(registry, atomRef.value) |
| 591 | return yield* awaitResult() |
| 592 | }) |
| 593 | const staleMs = staleTimeMsOf(normalizeQueryOptions(options)) |
| 594 | onMounted(() => { |
| 595 | if (!enabledRef.value) return |
| 596 | if (isStaleResult(registry.get(atomRef.value), staleMs)) refresh() |
| 597 | }) |
| 598 | const data = computed(() => Option.getOrUndefined(AsyncResult.value(result.value))) |
| 599 | |
| 600 | return { |
| 601 | result, |
| 602 | data, |
| 603 | awaitResult, |
| 604 | refetch, |
| 605 | refresh, |
| 606 | registry, |
| 607 | atom: atomRef |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | export const makeQueryFamily = <R>(_getRuntime: () => Context.Context<R>, getAtomRt: () => AtomClientRuntime) => { |
| 612 | const useQueryFamily: { |
| 613 | <I, E, A, Request extends Req, Name extends string>( |
| 614 | q: RequestHandlerWithInput<I, A, E, R, Request, Name> |
| 615 | ): QueryAtomFamily<I, A, E> |
| 616 | } = <I, E, A, Request extends Req, Name extends string>( |
| 617 | q: RequestHandlerWithInput<I, A, E, R, Request, Name> |
| 618 | ) => getQueryFamily(getAtomRt(), q) |
| 619 | |
| 620 | return useQueryFamily |
| 621 | } |
| 622 | |
| 623 | export const makeQueryAtom = <R>(_getRuntime: () => Context.Context<R>, getAtomRt: () => AtomClientRuntime) => { |
| 624 | const useQueryAtom: { |
| 625 | <I, E, A, Request extends Req, Name extends string>( |
| 626 | q: RequestHandlerWithInput<I, A, E, R, Request, Name> |
| 627 | ): { |
| 628 | <TData = A>( |
| 629 | arg: I, |
| 630 | options?: Omit<AtomQueryNewOptions<A, TData>, "select"> |
| 631 | ): Atom.Atom<AsyncResult.AsyncResult<A, E>> |
| 632 | } |
| 633 | } = <I, E, A, Request extends Req, Name extends string>( |
| 634 | q: RequestHandlerWithInput<I, A, E, R, Request, Name> |
| 635 | ) => |
| 636 | <TData = A>( |
| 637 | arg: I, |
| 638 | options?: Omit<AtomQueryNewOptions<A, TData>, "select"> |
| 639 | ) => queryAtomFor(getAtomRt(), q, arg, options) |
| 640 | |
| 641 | return useQueryAtom |
| 642 | } |
| 643 | |
| 644 | export const makeQueryNew = <R>(_getRuntime: () => Context.Context<R>, getAtomRt: () => AtomClientRuntime) => { |
| 645 | const useQueryNew: { |
| 646 | <I, E, A, Request extends Req, Name extends string>( |
| 647 | q: RequestHandlerWithInput<I, A, E, R, Request, Name> |
no test coverage detected
searching dependent graphs…