dispose method

Future<void> dispose()

Disposes this RxChatImpl.

Implementation

Future<void> dispose() async {
  Log.debug('dispose()', '$runtimeType($id)');

  _disposed = true;
  status.value = RxStatus.loading();
  messages.clear();
  reads.clear();
  members.dispose();
  _aroundToken.cancel();
  _muteTimer?.cancel();
  _readTimer?.cancel();
  _remoteSubscription?.close(immediate: true);
  _remoteSubscription = null;
  _localSubscription?.cancel();
  _localSubscription = null;
  _draftSubscription?.cancel();
  _draftSubscription = null;
  _paginationSubscription?.cancel();
  _pagination?.dispose();
  _messagesSubscription?.cancel();
  _callSubscription?.cancel();
  _membersPaginationSubscription?.cancel();
  status.value = RxStatus.empty();
  _worker?.dispose();
  _userWorker?.dispose();

  for (StreamSubscription s in _userSubscriptions.values) {
    s.cancel();
  }
  for (var e in fragments.toList()) {
    e.dispose();
  }
  for (final s in _fragmentSubscriptions) {
    s.cancel();
  }
  for (var e in _attachments.toList()) {
    e.dispose();
  }
}