@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
64 lines (63 loc) • 2.59 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
var LoadingCtl = /** @class */ (function () {
function LoadingCtl() {
this.isLoading = false;
}
LoadingCtl.prototype.start = function () {
this.isLoading = true;
};
LoadingCtl.prototype.stop = function () {
this.isLoading = false;
};
LoadingCtl.prototype.promise = function (promise) {
var _this = this;
this.start();
var stopLoading = function () { return _this.stop(); };
promise.then(stopLoading, stopLoading);
return promise;
};
LoadingCtl.prototype.handle = function () {
var thisPromise = this.promise.bind(this);
return function (_, __, descriptor) {
var oldValue = descriptor.value;
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var promise = oldValue.apply(this, args);
return thisPromise(promise);
};
return descriptor;
};
};
__decorate([
mobx_1.observable,
__metadata("design:type", Boolean)
], LoadingCtl.prototype, "isLoading", void 0);
__decorate([
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], LoadingCtl.prototype, "start", null);
__decorate([
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], LoadingCtl.prototype, "stop", null);
return LoadingCtl;
}());
exports.default = LoadingCtl;