Future<ValueUpdate> getNodeValue(String path, { Duration timeout })

Source

Future<ValueUpdate> getNodeValue(String path, {Duration timeout}) {
  var c = new Completer<ValueUpdate>();
  ReqSubscribeListener listener;
  Timer to;
  listener = subscribe(path, (ValueUpdate update) {
    if (!c.isCompleted) {
      c.complete(update);
    }

    if (listener != null) {
      listener.cancel();
      listener = null;
    }
    if (to != null && to.isActive) {
      to.cancel();
      to = null;
    }
  });
  if (timeout != null && timeout > Duration.ZERO) {
    to = new Timer(timeout, () {
      listener?.cancel();
      listener = null;

      c.completeError(new TimeoutException("failed to receive value", timeout));
    });
  }
  return c.future;
}