UNPKG

@iotile/iotile-common

Version:

Common utilities for IoTile Packages and Applications

41 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * @ngdoc object * @name IOTileAppModule.type:BlockingEvent * * @description * A concurrent event that allows waiting until a condition is met. Anyone who * calls wait() will yield and block until set() is called, at which point all * waiters will be released in parallel. * * @property {boolean} isSet Whether the event is set */ var BlockingEvent = /** @class */ (function () { function BlockingEvent() { this._set = false; var that = this; this.event = new Promise(function (resolve, reject) { that.resolve = resolve; }); } BlockingEvent.prototype.wait = function () { return this.event; }; BlockingEvent.prototype.set = function () { this._set = true; if (this.resolve) { this.resolve(); } }; Object.defineProperty(BlockingEvent.prototype, "isSet", { get: function () { return this._set; }, enumerable: true, configurable: true }); return BlockingEvent; }()); exports.BlockingEvent = BlockingEvent; //# sourceMappingURL=event.js.map