Adjust how error message is caught and displayed

This commit is contained in:
NI
2019-09-14 21:30:49 +08:00
parent 6b5c444f45
commit d9d0170d1a
8 changed files with 94 additions and 60 deletions

View File

@@ -29,6 +29,7 @@ export class Subscribe {
this.res = null;
this.rej = null;
this.pending = [];
this.disabled = null;
}
/**
@@ -78,6 +79,10 @@ export class Subscribe {
*
*/
subscribe() {
if (this.disabled) {
throw new Exception(this.disabled, false);
}
if (this.pending.length > 0) {
let p = this.pending.shift();
@@ -111,4 +116,14 @@ export class Subscribe {
};
});
}
/**
* Disable current subscriber when all internal data is readed
*
* @param {string} reason Reason of the disable
*
*/
disable(reason) {
this.disabled = reason;
}
}