@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
28 lines (27 loc) • 641 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const react_dom_1 = require("react-dom");
const BatchUpdate = (fn) => {
let fns = [];
if (fn) {
fns.push(fn);
}
const didCommit = false;
const queue = (fn) => {
fns.push(fn);
};
queue.commit = (lastFn) => {
if (didCommit) {
return;
}
if (lastFn) {
fns.push(lastFn);
}
(0, react_dom_1.unstable_batchedUpdates)(() => {
fns.forEach((fn) => fn());
fns = undefined;
});
};
return queue;
};
exports.default = BatchUpdate;