watchPoll method

Future<HGrid> watchPoll(
  1. HClientWatch w, {
  2. bool refresh = false,
})

Implementation

Future<HGrid> watchPoll(HClientWatch w, {bool refresh = false}) {
  if (w.id == null) throw StateError("nothing subscribed yet");
  if (w.isClosed) throw StateError("watch is closed");

  // grid meta
  var b = HGridBuilder();
  b.meta.add("watchId", w.id);
  b.addCol("empty");

  if (refresh) {
    b.meta.add("refresh");
  }

  // make request
  return call("watchPoll", b.toGrid()).catchError((Object e) {
    if (e is CallErrError) {
      // any server side error is considered close
      watchClose(w, send: false);
    }
    throw e;
  });
}