subscribe<T extends ParseObject> method

Future<Subscription<T>> subscribe<T extends ParseObject>(
  1. QueryBuilder<T> query, {
  2. T? copyObject,
})

Implementation

Future<Subscription<T>> subscribe<T extends ParseObject>(
    QueryBuilder<T> query,
    {T? copyObject}) async {
  if (_webSocket == null) {
    await _clientEventStream.any((LiveQueryClientEvent event) =>
        event == LiveQueryClientEvent.connected);
  }
  final int requestId = _requestIdGenerator();
  final Subscription<T> subscription =
      Subscription<T>(query, requestId, copyObject: copyObject);
  _requestSubscription[requestId] = subscription;
  //After a client connects to the LiveQuery server,
  //it can send a subscribe message to subscribe a ParseQuery.
  _subscribeLiveQuery(subscription);
  return subscription;
}