Skip to content

⬅️ Back to Table of Contents

📄 computedAsync

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 10
📊 Variables & Constants 1
🟢 Vue Composition API 1
📐 Interfaces 1
📑 Type Aliases 1

📚 Table of Contents

🛠️ File Location:

📂 packages/core/computedAsync/index.ts

📦 Imports

Name Source
ConfigurableFlushSync @vueuse/shared
Fn @vueuse/shared
ComputedRef vue
Ref vue
noop @vueuse/shared
computed vue
deepRef vue
isRef vue
shallowRef vue
watchEffect vue

Variables & Constants

Name Type Kind Value Exported
asyncComputed { <T>(evaluationCallback: (onCancel: ... const computedAsync

Vue Composition API

Name Type Reactive Variables Composables
computed computed none none

Functions

computedAsync(evaluationCallback: (onCancel: AsyncComputedOnCancel) => T …, initialState: T, optionsOrRef: AsyncComputedOptions<true>): ComputedRef<T>

Create an asynchronous computed dependency.

Parameters:

  • evaluationCallback any: The promise-returning callback which generates the computed value
  • initialState any: The initial state, used until the first evaluation finishes
  • optionsOrRef any: Additional options or a ref passed to receive the updates of the async evaluation

See: https://vueuse.org/computedAsync

Raw JSDoc
/**
 * Create an asynchronous computed dependency.
 *
 * @see https://vueuse.org/computedAsync
 * @param evaluationCallback     The promise-returning callback which generates the computed value
 * @param initialState           The initial state, used until the first evaluation finishes
 * @param optionsOrRef           Additional options or a ref passed to receive the updates of the async evaluation
 */
Code
export function computedAsync<T>(
  evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>,
  initialState: T,
  optionsOrRef: AsyncComputedOptions<true>,
): ComputedRef<T>

Interfaces

AsyncComputedOptions<Lazy = boolean>

Interface Code
export interface AsyncComputedOptions<Lazy = boolean> extends ConfigurableFlushSync {
  /**
   * Should value be evaluated lazily
   *
   * @default false
   */
  lazy?: Lazy

  /**
   * Ref passed to receive the updated of async evaluation
   */
  evaluating?: Ref<boolean>

  /**
   * Use shallowRef
   *
   * @default true
   */
  shallow?: boolean

  /**
   * Callback when error is caught.
   */
  onError?: (e: unknown) => void
}

Properties

Name Type Optional Description
lazy Lazy not shown
evaluating Ref<boolean> not shown
shallow boolean not shown
onError (e: unknown) => void not shown

Type Aliases

AsyncComputedOnCancel

/* * Handle overlapping async evaluations. * * @param cancelCallback The provided callback is invoked when a re-evaluation of the computed value is triggered before the previous one finished /

type AsyncComputedOnCancel = (cancelCallback: Fn) => void;

Generated by Syntax Scribe