UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

35 lines (28 loc) 947 B
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import { action } from 'mobx'; import debounce from 'lodash/debounce'; import { getIf } from '../data-set/utils'; var BatchRunner = /*#__PURE__*/function () { function BatchRunner() { var batchInterval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100; _classCallCheck(this, BatchRunner); this.run = debounce(action(function (tasks) { tasks.forEach(function (task) { return task(); }); tasks.clear(); }), batchInterval); } _createClass(BatchRunner, [{ key: "addTask", value: function addTask(key, callback) { this.run(getIf(this, 'task', function () { return new Map(); }).set(key, callback)); } }]); return BatchRunner; }(); export { BatchRunner as default }; //# sourceMappingURL=BatchRunner.js.map