Skip to content

Commit

Permalink
Fix Issue #13: Improve on() stream when no type is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
marcojakob committed May 13, 2015
1 parent 8e20a1a commit 447da02
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Version 0.4.1 (2015-05-13)

* Fix Issue #13: Improve on() stream when no type is specified


## Version 0.4.0 (2015-05-03)

* BREAKING CHANGE: Moved the `HierarchicalEventBus` to a separate library to
Expand Down
7 changes: 5 additions & 2 deletions lib/event_bus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ class EventBus {
* subscribe again (avoids memory leak).
*/
Stream on([Type eventType]) {
return streamController.stream.where((event) => eventType == null ||
event.runtimeType == eventType);
if (eventType == null) {
return streamController.stream;
} else {
return streamController.stream.where((event) => event.runtimeType == eventType);
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions lib/event_bus_hierarchical.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ class HierarchicalEventBus extends EventBus {
* subscribe again (avoids memory leak).
*/
Stream on([Type eventType]) {
return streamController.stream.where((event) => eventType == null ||
reflect(event).type.isSubclassOf(reflectClass(eventType)));
if (eventType == null) {
return streamController.stream;
} else {
return streamController.stream.where((event) =>
reflect(event).type.isSubclassOf(reflectClass(eventType)));
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: event_bus
version: 0.4.0
version: 0.4.1
author: Marco Jakob <[email protected]>
description: A simple Event Bus using Dart Streams for decoupling applications
homepage: http://code.makery.ch/library/dart-event-bus
Expand Down

0 comments on commit 447da02

Please sign in to comment.