getNodeValue method
Implementation
Future<ValueUpdate> getNodeValue(String path, {Duration? timeout}) {
var c = 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 = Timer(timeout, () {
listener?.cancel();
listener = null;
c.completeError(TimeoutException('failed to receive value', timeout));
});
}
return c.future;
}