subscribe method
Subscribe to realtime changes to the specified topic ("*" or record id).
If topic
is the wildcard "*", then this method will subscribe to
any record changes in the collection.
If topic
is a record id, then this method will subscribe only
to changes of the specified record id.
It's OK to subscribe multiple times to the same topic.
You can use the returned UnsubscribeFunc
to remove the subscription.
Or use unsubscribe(topic) if you want to remove all
subscriptions attached to the topic.
Implementation
Future<UnsubscribeFunc> subscribe(
String topic,
RecordSubscriptionFunc callback, {
String? expand,
String? filter,
String? fields,
Map<String, dynamic> query = const {},
Map<String, String> headers = const {},
}) {
return client.realtime.subscribe(
"$_collectionIdOrName/$topic",
(e) {
callback(RecordSubscriptionEvent.fromJson(e.jsonData()));
},
expand: expand,
filter: filter,
fields: fields,
query: query,
headers: headers,
);
}