Skip to content

Commit 447da02

Browse files
committed
Fix Issue #13: Improve on() stream when no type is specified
1 parent 8e20a1a commit 447da02

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Version 0.4.1 (2015-05-13)
4+
5+
* Fix Issue #13: Improve on() stream when no type is specified
6+
7+
38
## Version 0.4.0 (2015-05-03)
49

510
* BREAKING CHANGE: Moved the `HierarchicalEventBus` to a separate library to

lib/event_bus.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ class EventBus {
4545
* subscribe again (avoids memory leak).
4646
*/
4747
Stream on([Type eventType]) {
48-
return streamController.stream.where((event) => eventType == null ||
49-
event.runtimeType == eventType);
48+
if (eventType == null) {
49+
return streamController.stream;
50+
} else {
51+
return streamController.stream.where((event) => event.runtimeType == eventType);
52+
}
5053
}
5154

5255
/**

lib/event_bus_hierarchical.dart

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ class HierarchicalEventBus extends EventBus {
4040
* subscribe again (avoids memory leak).
4141
*/
4242
Stream on([Type eventType]) {
43-
return streamController.stream.where((event) => eventType == null ||
44-
reflect(event).type.isSubclassOf(reflectClass(eventType)));
43+
if (eventType == null) {
44+
return streamController.stream;
45+
} else {
46+
return streamController.stream.where((event) =>
47+
reflect(event).type.isSubclassOf(reflectClass(eventType)));
48+
}
4549
}
4650
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: event_bus
2-
version: 0.4.0
2+
version: 0.4.1
33
author: Marco Jakob <majakob@gmx.ch>
44
description: A simple Event Bus using Dart Streams for decoupling applications
55
homepage: http://code.makery.ch/library/dart-event-bus

0 commit comments

Comments
 (0)