- @override
Removes the node specified at path.
Source
@override
void removeNode(String path, {bool recurse: true}) {
if (path == '/' || !path.startsWith('/')) return;
SimpleNode node = getNode(path);
if (node == null) {
return;
}
if (recurse) {
String base = path;
if (!base.endsWith("/")) {
base += "/";
}
int baseSlashFreq = countCharacterFrequency(base, "/");
List<String> targets = nodes.keys.where((String x) {
return x.startsWith(base) &&
baseSlashFreq == countCharacterFrequency(x, "/");
}).toList();
for (String target in targets) {
removeNode(target);
}
}
Path p = new Path(path);
SimpleNode pnode = getNode(p.parentPath);
node.onRemoving();
node.removed = true;
if (pnode != null) {
pnode.children.remove(p.name);
pnode.onChildRemoved(p.name, node);
pnode.updateList(p.name);
}
if (node.callbacks.isEmpty && !node._hasListListener) {
nodes.remove(path);
} else {
node._stub = true;
}
}