rx-postmessenger
Version:
Minimal RxJS adapter for the window.postMessage API for request-response streams and notification streams across frame windows.
22 lines (21 loc) • 699 B
JavaScript
import { GUIDGenerator } from './functions/GUIDGenerator';
var MessageIDGenerator = /** @class */ (function () {
function MessageIDGenerator(gen) {
if (gen === void 0) { gen = GUIDGenerator(); }
this.gen = gen;
this.usedIDValues = [];
}
MessageIDGenerator.prototype.generateID = function () {
var newID;
do {
newID = this.gen.next().value;
} while (this.usedIDValues.indexOf(newID) >= 0);
this.invalidateID(newID);
return newID;
};
MessageIDGenerator.prototype.invalidateID = function (id) {
this.usedIDValues.push(id);
};
return MessageIDGenerator;
}());
export { MessageIDGenerator };