UNPKG

rx-postmessenger

Version:

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

36 lines (35 loc) 1.1 kB
var MessageFactory = /** @class */ (function () { function MessageFactory(IDGenerator) { this.IDGenerator = IDGenerator; } MessageFactory.prototype.makeNotification = function (channel, payload) { return { channel: channel, id: this.IDGenerator.generateID(), payload: payload, type: 'notification', }; }; MessageFactory.prototype.makeRequest = function (channel, payload) { return { channel: channel, id: this.IDGenerator.generateID(), payload: payload, type: 'request', }; }; MessageFactory.prototype.makeResponse = function (requestId, channel, payload) { return { channel: channel, id: this.IDGenerator.generateID(), payload: payload, requestId: requestId, type: 'response', }; }; MessageFactory.prototype.invalidateID = function (id) { this.IDGenerator.invalidateID(id); }; return MessageFactory; }()); export { MessageFactory };