Skip to content

Commit

Permalink
feat: Removed NotificationMessage class
Browse files Browse the repository at this point in the history
  • Loading branch information
pongloongyeat committed Jan 23, 2024
1 parent 8a73573 commit 40aec80
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
1 change: 1 addition & 0 deletions notification_dispatcher/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Breaking
- Removed `NotificationDispatcher.observers`.
- Removed `NotificationMessage` in favour of a simple `Map<String, dynamic>`.

### Documentation
- Tidied up documentation.
Expand Down
7 changes: 2 additions & 5 deletions notification_dispatcher/lib/src/notification_dispatcher.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'typedefs.dart';

part 'notification_message.dart';

/// Passes notifications around to registered observers. The class comes with a
/// default instance named [NotificationDispatcher.instance].
final class NotificationDispatcher {
Expand Down Expand Up @@ -54,12 +52,11 @@ final class NotificationDispatcher {
/// running all callbacks registered with [name].
/// {@endtemplate}
void post({
Object? sender,
required String name,
Map<String, dynamic>? info,
NotificationMessage? info,
}) {
for (final callback in _observers.values.toList()) {
callback[name]?.call(NotificationMessage._(sender: sender, info: info));
callback[name]?.call(info);
}

return;
Expand Down
15 changes: 0 additions & 15 deletions notification_dispatcher/lib/src/notification_message.dart

This file was deleted.

7 changes: 4 additions & 3 deletions notification_dispatcher/lib/src/typedefs.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'notification_dispatcher.dart';

/// Callback signature when receiving a notification.
typedef NotificationCallback = void Function(NotificationMessage message);
typedef NotificationCallback = void Function(NotificationMessage? message);

/// The message being posted/received.
typedef NotificationMessage = Map<String, dynamic>;

0 comments on commit 40aec80

Please sign in to comment.