watchClose method

Future<Object> watchClose(
  1. HClientWatch w, {
  2. bool send = true,
})

Implementation

Future<Object> watchClose(HClientWatch w, {bool send = true}) {
  // mark flag on watch itself, short circuit if already closed
  if (w.isClosed) {
    return Future.value();
  }

  w._closed = true;

  // remove it from my lookup table
  if (w.id != null) {
    _watches.remove(w.id);
  }

  // optionally send close message to server
  if (send) {
    HGridBuilder b = HGridBuilder();
    b.meta.add("watchId", w.id).add("close");
    b.addCol("id");

    // Ignoring any error while unsub.
    return call("watchUnsub", b.toGrid()).catchError((Object e) {});
  } else {
    return Future.value();
  }
}