@unilogin/sdk
Version:
SDK is a JS library, that communicates with relayer. SDK allows managing contract, by creating basic contract-calling messages.
42 lines • 1.7 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var reactive_properties_1 = require("reactive-properties");
var ReferenceCountedState = /** @class */ (function (_super) {
__extends(ReferenceCountedState, _super);
function ReferenceCountedState() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.subscribersCount = 0;
return _this;
}
ReferenceCountedState.prototype.subscribe = function (callback) {
var _this = this;
var unsubscribe = _super.prototype.subscribe.call(this, callback);
if (this.subscribersCount === 0) {
this.onFirstSubscribe();
}
this.subscribersCount++;
return function () {
_this.subscribersCount--;
if (_this.subscribersCount === 0) {
_this.onLastUnsubscribe();
}
unsubscribe();
};
};
return ReferenceCountedState;
}(reactive_properties_1.State));
exports.ReferenceCountedState = ReferenceCountedState;
//# sourceMappingURL=ReferenceCountedState.js.map
;