onPushReply method Null safety

Future<Message> onPushReply(
  1. PhoenixChannelEvent replyEvent
)

Returns a future that will complete (or throw) when the provided reply arrives (or throws).

Implementation

Future<Message> onPushReply(PhoenixChannelEvent replyEvent) {
  if (_waiters.containsKey(replyEvent)) {
    _logger.finer(
      () => 'Removing previous waiter for $replyEvent',
    );
    _waiters.remove(replyEvent);
  }
  _logger.finer(
    () => 'Hooking on channel $topic for reply to $replyEvent',
  );
  final completer = Completer<Message>();
  _waiters[replyEvent] = completer;
  completer.future.whenComplete(() => _waiters.remove(replyEvent));
  return completer.future;
}