pollEvents method

List<ObbyEvent> pollEvents()

Every event queued since the last call, as the typed ObbyEvent.

One crossing per drain rather than one per event, because a call over this boundary costs the same whether it carries one event or a hundred.

for (final event in client.pollEvents()) {
  switch (event) {
    case ObbyEventRegistered(:final nick):
      print('registered as $nick');
    case ObbyEventModelChanged(:final change):
      print(change);
    case ObbyEventServerReply(:final severity, :final code, :final text):
      print('${severity.wire} $code $text');
    default:
      break;
  }
}

Implementation

List<ObbyEvent> pollEvents() =>
    pollEventsJson().map(ObbyEvent.fromJson).toList();