stopObserving method

Future<void> stopObserving(
  1. String key,
  2. void listener(
    1. String? value,
    2. Participant? updatedBy
    )
)

Stops listener observing key.

Local cleanup always succeeds; when it was the key's last listener the server is told too, which needs a joined room.

Example

await room.realtimeStore.stopObserving("BLOCK_CHAT", onBlockChat);

Implementation

Future<void> stopObserving(
  String key,
  void Function(String? value, Participant? updatedBy) listener,
) async {
  final onEvent = _observers[key]?.remove(listener);
  if (onEvent == null) return;
  _realtimeStoreEventEmitter?.remove(key, onEvent);
  if (_observers[key]!.isNotEmpty) return;
  _observers.remove(key);
  if (!_ensureJoined("realtimeStore.stopObserving")) return;
  await _stopObserveInternal(key);
}