diff --git a/packages/shared/computedEager/index.ts b/packages/shared/computedEager/index.ts index 597904870ba..4002fd60b42 100644 --- a/packages/shared/computedEager/index.ts +++ b/packages/shared/computedEager/index.ts @@ -2,7 +2,7 @@ // by @linusborg https://github.com/LinusBorg import type { ShallowRef, WatchOptionsBase } from 'vue' -import { readonly, shallowRef, watchEffect } from 'vue' +import { computed } from 'vue' export type ComputedEagerOptions = WatchOptionsBase @@ -14,21 +14,13 @@ export type ComputedEagerReturn = Readonly> * computed, effect, watch, watchEffect, render dependencies will not be triggered. * refer: https://github.com/vuejs/core/pull/5912 * + * @deprecated - Replace with Vue's own computed function * @param fn effect function - * @param options WatchOptionsBase + * @param _ WatchOptionsBase * @returns readonly shallowRef */ -export function computedEager(fn: () => T, options?: ComputedEagerOptions): ComputedEagerReturn { - const result = shallowRef() - - watchEffect(() => { - result.value = fn() - }, { - ...options, - flush: options?.flush ?? 'sync', - }) - - return readonly(result) +export function computedEager(fn: () => T, _?: ComputedEagerOptions): ComputedEagerReturn { + return computed(fn) } // alias