state-switch
Version:
State Switch is a Change Monitor/Guarder for Async Actions.
26 lines • 625 B
JavaScript
import { StateSwitch } from './state-switch.js';
class BusyIndicator {
state;
constructor(...args) {
this.state = new 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');
}
}
export { BusyIndicator };
//# sourceMappingURL=busy-indicator.js.map