UNPKG

frontend-hamroun

Version:

A lightweight frontend JavaScript framework with React-like syntax

23 lines (22 loc) 425 B
export let isBatching = false; const queue = []; export function batchUpdates(fn) { if (isBatching) { queue.push(fn); return; } isBatching = true; try { fn(); while (queue.length > 0) { const nextFn = queue.shift(); nextFn?.(); } } finally { isBatching = false; } } export function getIsBatching() { return isBatching; }