UNPKG

rx-postmessenger

Version:

Minimal RxJS adapter for the window.postMessage API for request-response streams and notification streams across frame windows.

29 lines (28 loc) 936 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RxPostmessengerRequest = void 0; var RxPostmessengerRequest = /** @class */ (function () { function RxPostmessengerRequest(id, channel, payload, _injectResponse) { this.id = id; this.channel = channel; this.payload = payload; this._injectResponse = _injectResponse; this._isHandled = false; } Object.defineProperty(RxPostmessengerRequest.prototype, "isHandled", { get: function () { return this._isHandled; }, enumerable: false, configurable: true }); RxPostmessengerRequest.prototype.respond = function (data) { if (this._isHandled) { return; } this._injectResponse(data); this._isHandled = true; }; return RxPostmessengerRequest; }()); exports.RxPostmessengerRequest = RxPostmessengerRequest;