subscribe method
Returns a stream that emmits a PresenceMessage each time a matching
action
, or an action within an array of actions
, is received on the
channel, such as a new member entering the presence set.
There is no unsubscribe api in flutter like in other Ably client SDK's as subscribe returns a stream which can be used to create a cancellable stream subscription
Implementation
Stream<PresenceMessage> subscribe({
PresenceAction? action,
List<PresenceAction>? actions,
}) {
if (action != null) actions ??= [action];
return listen<PresenceMessage>(PlatformMethod.onRealtimePresenceMessage, {
TxTransportKeys.channelName: _channel.name,
}).where((presenceMessage) =>
actions == null || actions.contains(presenceMessage.action));
}