setBusyStatus method Null safety

void setBusyStatus(
  1. {required bool isBusy,
  2. dynamic busyTaskKey}
)

Explicitly updates the current busy status of the view model.

Can use this in conjunction with the EmpireState.ifBusy function on the EmpireState to show a loading indicator when performing a long running task. Can also determine the current busy status by accessing the busy property on the view model.

See doAsync for busyTaskKey usage.

Updating the busy status is automatic when using the doAsync function.

Implementation

void setBusyStatus({required bool isBusy, dynamic busyTaskKey}) {
  if (_busy != isBusy) {
    if (isBusy) {
      _addBusyTaskKey(busyTaskKey);
    } else {
      _removeBusyTaskKey(busyTaskKey);
    }
    _busy = isBusy;
    notifyChanges([EmpireStateChanged(isBusy, !isBusy)]);
  }
}