PDA

View Full Version : Simple question on db.addhandler



celestian
March 21st, 2017, 02:56
Why does this work (onSourceUpdate is called):




DB.addHandler(DB.getPath(node, "defenses.*"), "onChildUpdate", onSourceUpdate);


But this doesn't (onSourceUpdate is NOT called)?



DB.addHandler(DB.getPath(node, "defenses.ac.base"), "onChildUpdate", onSourceUpdate);
DB.addHandler(DB.getPath(node, "defenses.ac.shield"), "onChildUpdate", onSourceUpdate);
DB.addHandler(DB.getPath(node, "defenses.ac.misc"), "onChildUpdate", onSourceUpdate);


I've a need to individually add a handler for defenses.ac.base, defenses.ac.shield, defenses.ac.misc and not include defenses.ac.total. When I list them individually it doesn't call onSourceUpdate when those items are updated.

Trenloe
March 21st, 2017, 03:02
onChildUpdate will only trigger when child nodes of the one listed are updated. https://www.fantasygrounds.com/refdoc/databasenode.xcp#onChildUpdate

If you want to specify a specific node use onUpdate: https://www.fantasygrounds.com/refdoc/databasenode.xcp#onUpdate

celestian
March 21st, 2017, 03:53
onChildUpdate will only trigger when child nodes of the one listed are updated. https://www.fantasygrounds.com/refdoc/databasenode.xcp#onChildUpdate

If you want to specify a specific node use onUpdate: https://www.fantasygrounds.com/refdoc/databasenode.xcp#onUpdate

Oh gosh damn, I didn't even notice that slight difference!

Thanks ;)