getValue method

Future getValue(
  1. String soul, [
  2. TTMsgCb? cb
])

Traverse a location in the graph and Return the data

@param key Key to read data from @param cb @returns New link context corresponding to given key

Implementation

Future<dynamic> getValue(String soul, [TTMsgCb? cb]) async {
  final completer = Completer<dynamic>();
  VoidCallback dispose = () {};
  var completed = false;

  // Query the graph directly to avoid TTLink snapshot/once recursion.
  void onValue(dynamic value, [String? _, dynamic __]) {
    if (completed) return;
    completed = true;
    completer.complete(value);
    dispose();
  }

  dispose = graph.query([soul], onValue);
  // Proactively request the soul to ensure read-after-write over transports.
  final cleanup = graph.get(soul, cb);
  cleanup();

  return completer.future;
}