Skip to content

Commit

Permalink
Migrates onNotification to stream unwrapped Notification
Browse files Browse the repository at this point in the history
  • Loading branch information
obrunsmann committed Feb 18, 2023
1 parent a05e56a commit cda06e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* **Breaking:** Renamed `ChannelJoinType` enum to `ChannelType`
* **Breaking:** Renamed `leaderboardId` parameter to `leaderboardName` in `writeLeaderboardRecord` and `deleteLeaderboardRecord`
* **Breaking:** `onNotifications` is now a `Stream<Notification>` instead of `Stream<List<Notification>>`
* Added `onPartyData` stream to realtime client
* Added `listTournamentRecordsAroundOwner` to client

Expand Down
12 changes: 5 additions & 7 deletions lib/src/nakama_websocket_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ class NakamaWebsocketClient {
Stream<MatchPresenceEvent> get onMatchPresence =>
_onMatchPresenceController.stream;

final _onNotificationsController =
StreamController<List<Notification>>.broadcast();
final _onNotificationsController = StreamController<Notification>.broadcast();

Stream<List<Notification>> get onNotifications =>
_onNotificationsController.stream;
Stream<Notification> get onNotifications => _onNotificationsController.stream;

final _onStatusPresenceController =
StreamController<StatusPresenceEvent>.broadcast();
Expand Down Expand Up @@ -226,10 +224,10 @@ class NakamaWebsocketClient {
return _onMatchPresenceController.add(MatchPresenceEvent.fromDto(
receivedEnvelope.matchPresenceEvent));
case rtpb.Envelope_Message.notifications:
return _onNotificationsController.add(receivedEnvelope
.notifications.notifications
receivedEnvelope.notifications.notifications
.map((e) => Notification.fromDto(e))
.toList(growable: false));
.forEach((element) => _onNotificationsController.add(element));
return;
case rtpb.Envelope_Message.statusPresenceEvent:
return _onStatusPresenceController.add(StatusPresenceEvent.fromDto(
receivedEnvelope.statusPresenceEvent));
Expand Down

0 comments on commit cda06e3

Please sign in to comment.