@cran/lib.vue.ref
Version:
Vue Reactivity Extensions
32 lines (25 loc) • 599 B
text/typescript
import { type WatchSource, nextTick, watch } from "vue";
interface Update {
name: string;
next: unknown;
prev: unknown;
time: number;
}
let ticking = false;
const collector: Array<Update> = [ ];
/**
* @since 0.0.1
* @category Watch
*/
export function watchMonitor<T> ( name: string, source: WatchSource<T> ) {
return watch(source, function onSourceChange ( next, prev ) {
if (!ticking) {
ticking = true;
void nextTick(processQueue);
}
collector.push({ name, prev, next, time: performance.now(), });
});
}
function processQueue ( ) {
ticking = false;
}