watch method

dynamic watch({
  1. String? envId,
  2. String? collectionName,
  3. String? query,
  4. int? limit,
  5. Map<String, String>? orderBy,
  6. Function? onChange,
  7. Function? onError,
})

Implementation

watch({
  String? envId,
  String? collectionName,
  String? query,
  int? limit,
  Map<String, String>? orderBy,
  Function? onChange,
  Function? onError,
}) {
  if (this._ws == null && this._wsInitPromise == null) {
    this._initWebSocketConnection(reconnect: false);
  }

  var virtualClient = VirtualWebSocketClient(
    envId: envId,
    collectionName: collectionName,
    query: query,
    limit: limit,
    orderBy: orderBy,
    send: this.send,
    login: this._webLogin,
    isWSConnected: this._isWSConnected,
    onceWSConnected: this._onceWSConnected,
    getWaitExpectedTimeoutLength: this._getWaitExpectedTimeoutLength,
    onWatchStart: this._onWatchStart,
    onWatchClose: this._onWatchClose,
    debug: true,
    onChange: onChange,
    onError: onError,
  );
  this._virtualWSClient.add(virtualClient);
  this._watchIdClientMap[virtualClient.watchId] = virtualClient;
  return virtualClient.listener;
}