@yesstudio/nuxt-composables
    Preparing search index...

    Function useAsyncComputed

    Computes an asynchronous value, updating the reference when the effect resolves.

    const data = useAsyncComputed<{ downloads: number; end: string; package: string; start: string } | null>(
    (onCancel) => {
    const controller = new AbortController()
    onCancel(() => controller.abort())
    const url = new URL('https://api.npmjs.org/downloads/point/last-week/vue')
    const request = new Request(url, { signal: controller.signal })
    return fetch(request).then((response) => response.json())
    },
    () => null,
    )

    The type of the computed value.

    The asynchronous effect that computes the value.

    Optional function that returns an initial value for the computed value.

    Optional configuration options.

    A reactive reference that contains the computed value or undefined if not initialised.

    • Computes an asynchronous value, updating the reference when the effect resolves.

      Type Parameters

      • T

        The type of the computed value.

      Parameters

      Returns Ref<T | undefined>

      A reactive reference that contains the computed value or undefined until the effect resolves.

      const data = useAsyncComputed<{ downloads: number; end: string; package: string; start: string }>((onCancel) => {
      const controller = new AbortController()
      onCancel(() => controller.abort())
      const url = new URL('https://api.npmjs.org/downloads/point/last-week/vue')
      const request = new Request(url, { signal: controller.signal })
      return fetch(request).then((response) => response.json())
      })
    • Computes an asynchronous value, updating the reference when the effect resolves.

      Type Parameters

      • T

        The type of the computed value.

      Parameters

      Returns Ref<T>

      A reactive reference that contains the computed value or the initial value until the effect resolves.

      const data = useAsyncComputed<{ downloads: number; end: string; package: string; start: string } | null>(
      (onCancel) => {
      const controller = new AbortController()
      onCancel(() => controller.abort())
      const url = new URL('https://api.npmjs.org/downloads/point/last-week/vue')
      const request = new Request(url, { signal: controller.signal })
      return fetch(request).then((response) => response.json())
      },
      () => null,
      )