watch method

RealtimeListener watch({
  1. void onChange(
    1. Snapshot snapshot
    )?,
  2. void onError(
    1. dynamic error
    )?,
})

Implementation

RealtimeListener watch({
  void onChange(Snapshot snapshot)?,
  void onError(error)?,
}) {
  Map<String, String> orderBy = {};
  this._fieldOrders!.forEach((order) {
    orderBy[order.field] = order.direction;
  });

  return RealtimeWebSocketClient.getInstance(this._core).watch(
    envId: this._core.config.envId,
    collectionName: this._coll,
    query: jsonEncode(this._fieldFilters),
    limit: min(this._queryOptions!.limit ?? 0, 1000),
    orderBy: orderBy,
    onChange: onChange,
    onError: onError,
  );
}