onStatusChange method
Allows to subscribe to connection status changes and handle connection errors.
Implementation
Function onStatusChange(void Function(dynamic value) callback,
[void Function(dynamic value)? errorsHandler]) {
_statusChangeSubscriptions.add(callback);
if (errorsHandler != null) {
_statusChangeErrorSubscriptions.add(errorsHandler);
}
unsubscribe() {
if (_statusChangeSubscriptions.contains(callback)) {
_statusChangeSubscriptions.remove(callback);
}
if (errorsHandler != null &&
_statusChangeErrorSubscriptions.contains(errorsHandler)) {
_statusChangeErrorSubscriptions.remove(errorsHandler);
}
}
return unsubscribe;
}