diff --git a/notification_dispatcher/CHANGELOG.md b/notification_dispatcher/CHANGELOG.md index a526ded..de89674 100644 --- a/notification_dispatcher/CHANGELOG.md +++ b/notification_dispatcher/CHANGELOG.md @@ -13,6 +13,7 @@ ### Breaking - Removed `NotificationDispatcher.observers`. +- Removed `NotificationMessage` in favour of a simple `Map`. ### Documentation - Tidied up documentation. diff --git a/notification_dispatcher/lib/src/notification_dispatcher.dart b/notification_dispatcher/lib/src/notification_dispatcher.dart index fe11fde..5268d1b 100644 --- a/notification_dispatcher/lib/src/notification_dispatcher.dart +++ b/notification_dispatcher/lib/src/notification_dispatcher.dart @@ -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 { @@ -54,12 +52,11 @@ final class NotificationDispatcher { /// running all callbacks registered with [name]. /// {@endtemplate} void post({ - Object? sender, required String name, - Map? info, + NotificationMessage? info, }) { for (final callback in _observers.values.toList()) { - callback[name]?.call(NotificationMessage._(sender: sender, info: info)); + callback[name]?.call(info); } return; diff --git a/notification_dispatcher/lib/src/notification_message.dart b/notification_dispatcher/lib/src/notification_message.dart deleted file mode 100644 index 05ef2e2..0000000 --- a/notification_dispatcher/lib/src/notification_message.dart +++ /dev/null @@ -1,15 +0,0 @@ -part of 'notification_dispatcher.dart'; - -/// The class used to store a notification's payload. -final class NotificationMessage { - const NotificationMessage._({ - required this.sender, - required this.info, - }); - - /// The sender posting the notification - final Object? sender; - - /// The info being posted with the notification. - final Map? info; -} diff --git a/notification_dispatcher/lib/src/typedefs.dart b/notification_dispatcher/lib/src/typedefs.dart index b89fbf1..64a3934 100644 --- a/notification_dispatcher/lib/src/typedefs.dart +++ b/notification_dispatcher/lib/src/typedefs.dart @@ -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;