🌈 An enterprise-class UI components based on Ant Design and Vue. 🐜
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

16 lines
431 B

import { watchEffect, shallowRef } from 'vue';
import type { ComputedRef } from 'vue';
export declare type ComputedGetter<T> = (...args: any[]) => T;
export default function eagerComputed<T>(fn: ComputedGetter<T>) {
const result = shallowRef<T>();
watchEffect(
() => {
result.value = fn();
},
{
flush: 'sync', // needed so updates are immediate.
},
);
return result as any as ComputedRef<T>;
}