UNPKG

@dark-engine/core

Version:

The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)

31 lines (30 loc) 866 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports.addBatch = exports.batch = void 0; const scope_1 = require('../scope'); function batch(callback) { const $scope = (0, scope_1.$$scope)(); $scope.setIsBatch(true); callback(); $scope.setIsBatch(false); } exports.batch = batch; function addBatch(hook, callback, change) { const $scope = (0, scope_1.$$scope)(); if ($scope.getIsTransition()) { callback(); } else { const batch = hook.getBatch() || { timer: null, changes: [] }; hook.setBatch(batch); batch.changes.push(change); batch.timer && clearTimeout(batch.timer); batch.timer = setTimeout(() => { batch.changes.splice(-1); batch.changes.forEach(x => x()); hook.setBatch(null); callback(); }); } } exports.addBatch = addBatch; //# sourceMappingURL=batch.js.map