|
1 | 1 | import type { Fn } from '@vueuse/shared'
|
2 |
| -import type { Ref } from 'vue' |
| 2 | +import type { ComputedRef, Ref } from 'vue' |
3 | 3 | import { noop } from '@vueuse/shared'
|
4 | 4 | import {
|
5 | 5 | computed,
|
@@ -63,18 +63,28 @@ export interface AsyncComputedOptions {
|
63 | 63 | export function computedAsync<T>(
|
64 | 64 | evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>,
|
65 | 65 | initialState: T,
|
66 |
| - optionsOrRef?: Ref<boolean> | AsyncComputedOptions, |
| 66 | + optionsOrRef: AsyncComputedOptions & { lazy: true }, |
| 67 | +): ComputedRef<T> |
| 68 | +export function computedAsync<T>( |
| 69 | + evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>, |
| 70 | + initialState: undefined, |
| 71 | + optionsOrRef: AsyncComputedOptions & { lazy: true }, |
| 72 | +): ComputedRef<T | undefined> |
| 73 | +export function computedAsync<T>( |
| 74 | + evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>, |
| 75 | + initialState: T, |
| 76 | + optionsOrRef?: Ref<boolean> | (AsyncComputedOptions & { lazy?: false | undefined }), |
67 | 77 | ): Ref<T>
|
68 | 78 | export function computedAsync<T>(
|
69 | 79 | evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>,
|
70 | 80 | initialState?: undefined,
|
71 |
| - optionsOrRef?: Ref<boolean> | AsyncComputedOptions, |
| 81 | + optionsOrRef?: Ref<boolean> | (AsyncComputedOptions & { lazy?: false | undefined }), |
72 | 82 | ): Ref<T | undefined>
|
73 | 83 | export function computedAsync<T>(
|
74 | 84 | evaluationCallback: (onCancel: AsyncComputedOnCancel) => T | Promise<T>,
|
75 | 85 | initialState?: T,
|
76 | 86 | optionsOrRef?: Ref<boolean> | AsyncComputedOptions,
|
77 |
| -): Ref<T> | Ref<T | undefined> { |
| 87 | +): Ref<T> | Ref<T | undefined> | ComputedRef<T> | ComputedRef<T | undefined> { |
78 | 88 | let options: AsyncComputedOptions
|
79 | 89 |
|
80 | 90 | if (isRef(optionsOrRef)) {
|
|
0 commit comments