state-switch
Version:
State Switch is a Change Monitor/Guarder for Async Actions.
29 lines • 772 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BusyIndicator = void 0;
const state_switch_js_1 = require("./state-switch.js");
class BusyIndicator {
state;
constructor(...args) {
this.state = new state_switch_js_1.StateSwitch(...args);
}
busy(b) {
if (typeof b === 'undefined') {
return !!(this.state.active());
}
if (b) {
this.state.active(true);
}
else {
this.state.inactive(true);
}
}
/**
* Return a Promise that resolves when the busy state is off
*/
async idle() {
await this.state.stable('inactive');
}
}
exports.BusyIndicator = BusyIndicator;
//# sourceMappingURL=busy-indicator.js.map