@tamagui/react-native-web-lite
Version:
React Native for Web
62 lines (61 loc) • 2.53 kB
JavaScript
import { InteractionManager } from "@tamagui/react-native-web-internals";
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _create_class(Constructor, protoProps, staticProps) {
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor;
}
function _define_property(obj, key, value) {
return key in obj ? Object.defineProperty(obj, key, {
value,
enumerable: !0,
configurable: !0,
writable: !0
}) : obj[key] = value, obj;
}
var Batchinator = /* @__PURE__ */function () {
function Batchinator2(callback, delayMS) {
_class_call_check(this, Batchinator2), _define_property(this, "_callback", void 0), _define_property(this, "_delay", void 0), _define_property(this, "_taskHandle", void 0), this._delay = delayMS, this._callback = callback;
}
return _create_class(Batchinator2, [{
/*
* Cleanup any pending tasks.
*
* By default, if there is a pending task the callback is run immediately. Set the option abort to
* true to not call the callback if it was pending.
*/
key: "dispose",
value: function () {
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
abort: !1
};
this._taskHandle && (this._taskHandle.cancel(), options.abort || this._callback(), this._taskHandle = null);
}
}, {
key: "schedule",
value: function () {
var _this = this;
if (!this._taskHandle) {
var timeoutHandle = setTimeout(function () {
_this._taskHandle = InteractionManager.runAfterInteractions(function () {
_this._taskHandle = null, _this._callback();
});
}, this._delay);
this._taskHandle = {
cancel: function () {
return clearTimeout(timeoutHandle);
}
};
}
}
}]), Batchinator2;
}(),
Batchinator_default = Batchinator;
export { Batchinator_default as default };
//# sourceMappingURL=index.native.js.map