penpal
Version:
A promise-based library for communicating with iframes via postMessage.
26 lines (21 loc) • 442 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = () => {
const callbacks = [];
let destroyed = false;
return {
destroy(error) {
destroyed = true;
callbacks.forEach(callback => {
callback(error);
});
},
onDestroy(callback) {
destroyed ? callback() : callbacks.push(callback);
}
};
};
exports.default = _default;