getPathSouls method
Implementation
Future<List<String>> getPathSouls(List<String> path) async {
var completer = Completer<List<String>>();
if (path.length == 1) {
completer.complete(path);
}
List<String> lastSouls = [];
updateQuery(TTNode? _, [dynamic __, dynamic ___]) {
PathData getPathDataList = getPathData(path, _graph);
List<String> souls = getPathDataList.souls;
bool complete = getPathDataList.complete;
// print('updateQuery: ${souls.toString()} -- $complete');
final diffSetsList = diffSets(lastSouls, souls);
dynamic added = diffSetsList[0];
dynamic removed = diffSetsList[1];
// print('diffSetsList:: ${added.toString()} -- ${removed.toString()}');
end() {
for (final soul in lastSouls) {
_unlistenSoul(soul, updateQuery);
}
lastSouls = [];
}
if (complete) {
end();
if (!completer.isCompleted) {
completer.complete(souls);
}
return;
} else {
for (final soul in added) {
_requestSoul(soul, updateQuery);
}
for (final soul in removed) {
_unlistenSoul(soul, updateQuery);
}
}
lastSouls = souls;
}
updateQuery(null);
return completer.future;
}