@crossed/sheet
Version:
A Cross Platform(Android & iOS) ActionSheet with a robust and flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
63 lines (62 loc) • 2.1 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: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__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: true }), mod);
var eventmanager_exports = {};
__export(eventmanager_exports, {
actionSheetEventManager: () => actionSheetEventManager,
default: () => eventmanager_default
});
module.exports = __toCommonJS(eventmanager_exports);
class EventManager {
_registry;
constructor() {
this._registry = /* @__PURE__ */ new Map();
}
unsubscribeAll() {
this._registry.clear();
}
subscribe(name, handler, once = false) {
if (!name || !handler)
throw new Error("name and handler are required.");
this._registry.set(handler, { name, once });
return { unsubscribe: () => this.unsubscribe(name, handler) };
}
unsubscribe(_name, handler) {
return this._registry.delete(handler);
}
publish(name, ...args) {
this._registry.forEach((props, handler) => {
if (props.name === name)
handler(...args);
if (props.once)
this._registry.delete(handler);
});
}
remove(...names) {
this._registry.forEach((props, handler) => {
if (names.includes(props.name))
this._registry.delete(handler);
});
}
}
var eventmanager_default = EventManager;
const actionSheetEventManager = new EventManager();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
actionSheetEventManager
});
//# sourceMappingURL=eventmanager.js.map