@test-org122/utils
Version:
Utilities used by Hypernet Labs packages
34 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChildProxy = void 0;
const neverthrow_1 = require("neverthrow");
class IFrameCallData {
constructor(callId, data) {
this.callId = callId;
this.data = data;
}
}
class ChildProxy {
activateModel() {
const handshake = this.getModel();
return neverthrow_1.ResultAsync.fromPromise(handshake.then((initializedParent) => {
this.parent = initializedParent;
this.onModelActivated(initializedParent);
return initializedParent;
}), (e) => e);
}
returnForModel(func, callId) {
func().match((result) => {
if (this.parent != null) {
this.parent.emit("callSuccess", new IFrameCallData(callId, result));
}
}, (e) => {
if (this.parent != null) {
console.error(e);
this.parent.emit("callError", new IFrameCallData(callId, e));
}
});
}
}
exports.ChildProxy = ChildProxy;
//# sourceMappingURL=ChildProxy.js.map