marcojakob / dart-event-bus

An Event Bus using Dart Streams for decoupling applications
MIT License
755 stars 82 forks source link

Improve on() stream when no type is specified #13

Closed marcojakob closed 9 years ago

marcojakob commented 9 years ago

Use a null check and return the entire stream instead of always filtering the stream with where.

Stream on([Type eventType]) {
  if (eventType == null) {
    return streamController.stream;
  } else {
    return streamController.stream.where((event) => event.runtimeType == eventType);
  }
}

Note: Applies to EventBus and HierarchicalEventBus.