isSubscribed method
Implementation
@override
Future<bool> isSubscribed(String topic) async {
// topic subscription is already resolved
if (topics.contains(topic)) return true;
// wait for the subscription to resolve
final watch = Stopwatch();
watch.start();
final completer = Completer<bool>();
Timer.periodic(Duration(milliseconds: _pendingSubInterval), (timer) {
if (!pending.containsKey(topic) && topics.contains(topic)) {
timer.cancel();
watch.stop();
completer.complete(true);
}
if (watch.elapsedMilliseconds >= PENDING_SUB_RESOLUTION_TIMEOUT) {
timer.cancel();
watch.stop();
completer.complete(false);
}
});
return completer.future;
}