Skip to content

Commit

Permalink
feat: Added onSystemEvents listener (#1025)
Browse files Browse the repository at this point in the history
* feat: Added onSystemEvents listener

* change the type of payload

* change the type of parameter for onSystemEvents
  • Loading branch information
dshukertjr authored Sep 5, 2024
1 parent ec5d47e commit a12b097
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/realtime_client/lib/src/realtime_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,17 @@ class RealtimeChannel {
);
}

/// Sets up a listener for realtime system events for debugging purposes.
RealtimeChannel onSystemEvents(
void Function(dynamic payload) callback,
) {
return onEvents(
'system',
ChannelFilter(),
(payload, [ref]) => callback(payload),
);
}

@internal
RealtimeChannel onEvents(
String type, ChannelFilter filter, BindingCallback callback) {
Expand Down
2 changes: 1 addition & 1 deletion packages/realtime_client/lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ enum ChannelResponse {
error
}

enum RealtimeListenTypes { postgresChanges, broadcast, presence }
enum RealtimeListenTypes { postgresChanges, broadcast, presence, system }

enum PresenceEvent { sync, join, leave }

Expand Down

0 comments on commit a12b097

Please sign in to comment.