BroadcastState constructor

BroadcastState({
  1. required Duration timeout,
  2. double considerDonePercent = 1,
})

creates a new BroadcastState instance

Implementation

BroadcastState({
  required this.timeout,
  this.considerDonePercent = 1,
}) {
  _networkSubscription = networkController.stream.listen((response) {
    // got a response from a relay
    broadcasts[response.relayUrl] = response;
    // send state update
    _stateUpdatesController.add(this);
    // check if all relays responded
    _checkBroadcastDone();
  });

  Future.delayed(timeout, () {
    if (!publishDone) {
      _stateUpdatesController.add(this);
      _dispose();
    }
  });
}