(_getRuntime: () => Context.Context<R>, getAtomRt: () => AtomClientRuntime)
| 562 | options?: (AtomQueryNewOptions<A, TData> | CustomUseQueryOptions<A, E, TData>) & { |
| 563 | readonly mode?: "optional" |
| 564 | } |
| 565 | ): QueryView<TData, E> => { |
| 566 | const atomRt = getAtomRt() |
| 567 | const registry = injectRegistry() |
| 568 | const [req, enabledRef] = optionValue<I>(arg, options) |
| 569 | const family = getQueryFamily(atomRt, q) |
| 570 | const atomRef = computed(() => enabledRef.value ? observedAtom(family(req.value), options) : disabledQueryAtom) |
| 571 | // useAtomValue returns Readonly<Ref>, not ComputedRef — re-wrap before withDataFallback / QueryView. |
| 572 | const rawAtomResult = useAtomValue(() => atomRef.value) |
| 573 | const rawResult = computed(() => rawAtomResult.value) |
| 574 | // `initialData` / `placeholderData` display fallback (old `.query()` API). Applied only while the |
| 575 | // result is still Initial; Failures/Success pass through unmasked. Neither is written to cache |
| 576 | // (the base atom stays Initial, so the mount-staleness check still triggers the real fetch). The |
| 577 | // fallback runs PRE-select, matching TanStack (`initialData`/`placeholderData` are TQueryData). |
| 578 | const fallbackResult = withDataFallback(rawResult, options) |
| 579 | const select = options?.select |
| 580 | const result = (select |
| 581 | ? computed(() => AsyncResult.map(fallbackResult.value, select)) |
| 582 | : fallbackResult) as ComputedRef<AsyncResult.AsyncResult<TData, E>> |
| 583 | const refresh = () => registry.refresh(atomRef.value) |
| 584 | const awaitResult = () => |
| 585 | select |
| 586 | ? awaitAtomResult(registry, atomRef.value).pipe(Effect.map(select)) |
| 587 | : awaitAtomResult(registry, atomRef.value) |
| 588 | const refetch = () => |
| 589 | Effect.gen(function*() { |
| 590 | yield* refreshAtomWithCurrentSpan(registry, atomRef.value) |
| 591 | return yield* awaitResult() |
no outgoing calls
no test coverage detected
searching dependent graphs…