Skip to content

Commit

Permalink
Fix issue #6: Fire should accept null as data
Browse files Browse the repository at this point in the history
  • Loading branch information
marcojakob committed Jul 1, 2013
1 parent 2bbaed2 commit dee177e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ Changelog
* Using Darts new Stream.broadcast() factory.
* Provide option for synchronous broadcasting of events.
* Update unit tests and example.
* Create demo page.
* Create demo page.

## Version 0.2.1 (2013-07-01) ##
* Fix issue #6: Fire should accept null as data
4 changes: 2 additions & 2 deletions lib/src/simple_event_bus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class SimpleEventBus implements EventBus {
}

void fire(EventType/*<T>*/ eventType, /*<T>*/ data) {
if (!eventType.isTypeT(data)) {
throw new ArgumentError('Provided data is not of same type as generic type of EventType.');
if (data != null && !eventType.isTypeT(data)) {
throw new ArgumentError('Provided data is not of same type as T of EventType.');
}

var controller = streamControllers[eventType];
Expand Down
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.2.0
version: 0.2.1
author: Marco Jakob <majakob@gmx.ch>
description: A simple Event Bus using Dart Streams for decoupling applications
homepage: https://github.com/marcojakob/dart-event-bus
Expand Down
8 changes: 8 additions & 0 deletions test/src/simple_event_bus_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ group('[SimpleEventBus]', () {
test('fire_WrongDataType_ThrowsError', () {
expect(() => eventBus.fire(stringEvent1, 22), throwsArgumentError);
});

test('fire_NullAsData_NoError', () {
try {
eventBus.fire(stringEvent1, null);
} catch (e) {
fail('Should not throw error: $e');
}
});
});
}

Expand Down

0 comments on commit dee177e

Please sign in to comment.