updateAsync method

  1. @mustCallSuper
Future<void> updateAsync(
  1. covariant Function fnUpdate
)

Executes fnUpdate, and notify the listeners about to update as async way.

Implementation

@mustCallSuper
Future<void> updateAsync(covariant Function fnUpdate) async {
  assert(!_isDisposed, "You can update when it's been disposed");

  if (!_hasListeners || _isUpdating) {
    return await fnUpdate();
  }

  _isUpdating = true;

  await _notifyAsync(Lifecycle.willUpdate);
  await fnUpdate();
  await _notifyAsync(Lifecycle.didUpdate);

  _isUpdating = false;
}