MCPcopy Create free account
hub / github.com/effect-app/libs / makeQueryView

Function makeQueryView

packages/vue/src/query.ts:485–529  ·  view source on GitHub ↗
(
  getAtomRt: () => AtomClientRuntime,
  q: QueryFamilyDescriptor<I, A, E>,
  arg: I | WatchSource<I> | undefined | WatchSource<Option.Option<I>>,
  options?: (AtomQueryNewOptions<A, TData> | CustomUseQueryOptions<A, E, TData>) & {
    readonly mode?: "optional"
  }
)

Source from the content-addressed store, hash-verified

483 registry,
484 atom: atomRef
485 }
486}
487
488const optionValue = <I>(
489 arr: I | WatchSource<I> | undefined | WatchSource<Option.Option<I>>,
490 options?: { readonly mode?: "optional"; readonly enabled?: MaybeRefOrGetter<boolean | undefined> }
491): readonly [{ readonly value: I }, ComputedRef<boolean>] => {
492 if (options?.mode === "optional") {
493 const getOption: () => Option.Option<I> = typeof arr === "function"
494 ? arr as () => Option.Option<I>
495 : () => (arr as { value: Option.Option<I> }).value
496 return [
497 {
498 get value() {
499 return Option.getOrUndefined(getOption()) as I
500 }
501 },
502 computed(() => Option.isSome(getOption()))
503 ] as const
504 }
505 const req = !arr
506 ? ({ value: undefined as I })
507 : typeof arr === "function"
508 ? ({
509 get value() {
510 return (arr as any)()
511 }
512 })
513 : (ref(arr) as any)
514 const enabled = options?.enabled
515 return [req, computed(() => enabled === undefined ? true : !!toValue(enabled))] as const
516}
517
518const observedAtom = <A, E>(
519 atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>,
520 options?: {
521 readonly staleTime?: number
522 readonly gcTime?: number | "infinity"
523 readonly idleTTL?: number | "infinity"
524 readonly refetchOnWindowFocus?: boolean
525 readonly revalidateOnFocus?: boolean
526 readonly structuralSharing?: boolean
527 readonly refetchInterval?: number
528 readonly refreshEvery?: number
529 readonly live?: boolean | LiveQueryOptions
530 readonly invalidation?: QueryInvalidationMode
531 }
532): Atom.Atom<AsyncResult.AsyncResult<A, E>> =>

Callers 2

useQueryNewFunction · 0.85
useQuery_Function · 0.85

Calls 14

staleTimeMsOfFunction · 0.90
isStaleResultFunction · 0.90
getAtomRtFunction · 0.85
injectRegistryFunction · 0.85
optionValueFunction · 0.85
getQueryFamilyFunction · 0.85
computedFunction · 0.85
observedAtomFunction · 0.85
normalizeQueryOptionsFunction · 0.85
refreshFunction · 0.70
mapMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…