syncUpdate method

FutureOr<T> syncUpdate(
  1. T current
)

When setting a value in this way, we can assume that this update is the latest, and should cancel out any other in-flight requests

Implementation

FutureOr<T> syncUpdate(T current) {
  switch (mode) {
    case ClearingHouseMode.AllowSynchronousValues:
      final requestId = _requestId++;
      // Cancel any in-flight update, then update (after the cancellation completes)

      if (_inflight != null) {
        log.info("Cancelling inflight update");
        _inflight!.cancel().ignore();
        _inflight = null;
      }
      _internalUpdate(requestId, current);
      _nextFrame
        ..start()
        ..complete(current)
        ..reset();

      return future;
    default:
      if (_queue(() => current, debugLabel: "sync: $current")) {
        return future;
      } else {
        return Future.value(_current);
      }
  }
}