@tamagui/react-native-web-lite
Version:
React Native for Web
84 lines (83 loc) • 3.45 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var Batchinator_exports = {};
__export(Batchinator_exports, {
default: () => Batchinator_default
});
module.exports = __toCommonJS(Batchinator_exports);
var import_react_native_web_internals = require("@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 = import_react_native_web_internals.InteractionManager.runAfterInteractions(function() {
_this._taskHandle = null, _this._callback();
});
}, this._delay);
this._taskHandle = {
cancel: function() {
return clearTimeout(timeoutHandle);
}
};
}
}
}
]), Batchinator2;
}(), Batchinator_default = Batchinator;
//# sourceMappingURL=index.js.map