- @override
Adds a node at the given path that is initialized with the given data in m.
Source
@override
SimpleNode addNode(String path, Map m) {
if (path == '/' || !path.startsWith('/')) return null;
Path p = new Path(path);
SimpleNode oldNode = _getNode(path, allowStubs: true);
SimpleNode pnode = getNode(p.parentPath);
SimpleNode node;
if (pnode != null) {
node = pnode.onLoadChild(p.name, m, this);
}
if (node == null) {
String profile = m[r'$is'];
if (_profiles.containsKey(profile)) {
node = _profiles[profile](path);
} else {
node = getOrCreateNode(path, true, false);
}
}
if (oldNode != null) {
logger.fine("Found old node for ${path}: Copying subscriptions.");
for (ValueUpdateCallback func in oldNode.callbacks.keys) {
node.subscribe(func, oldNode.callbacks[func]);
}
if (node is SimpleNode) {
try {
node._listChangeController = oldNode._listChangeController;
node._listChangeController.onStartListen = () {
node.onStartListListen();
};
node._listChangeController.onAllCancel = () {
node.onAllListCancel();
};
} catch (e) {}
if (node._hasListListener) {
node.onStartListListen();
}
}
}
nodes[path] = node;
node.load(m);
node.onCreated();
if (pnode != null) {
pnode.addChild(p.name, node);
pnode.onChildAdded(p.name, node);
pnode.updateList(p.name);
}
node.updateList(r"$is");
if (oldNode != null) {
oldNode.updateList(r"$is");
}
return node;
}