unsubscribeByPrefix method
Unsubscribe from all subscription listeners starting with the specified topic prefix.
This method is no-op if there are no active subscriptions with the specified topic prefix.
The related SSE connection will be autoclosed if after the unsubscribe operation there are no active subscriptions left.
Implementation
Future<void> unsubscribeByPrefix(String topicPrefix) async {
// remove matching subscriptions
_subscriptions.removeWhere((key, func) {
// "?" so that it can be used as end delimiter for the prefix
return "$key?".startsWith(topicPrefix);
});
return _submitSubscriptions();
}