PDA

View Full Version : Potential Issue with Add Handler Documentation?



MadNomadGM
September 14th, 2020, 16:05
Hi, I am really struggling with

function addHandler( nodepath, event, callback )
* [onChildUpdate] parameters = (nodeParent, nodeChildUpdated)

https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4063529/DB

The other handlers work intuitively, but the onChildUpdate does not do what I'd expect. I would expect it to return the DB path of parent and the DB path of the child that was updated.

I have it "working" and it is correctly returning the expected parent path, but instead of retuning the "nodeChildUpdated" path as shown in the documentation, it's returning a boolean value. I have no idea what that value would be. It is also firing multiple times on a single update.
I made some guesses and tested, but none of them seem right.

1. Thought it might be whether or not a child was actually updated. This doesnt make sense though because it has to be true in order for the handler to fire, so doesn't explain why I am ever getting false.
2. The handler will fire multiple times when I do this, so thought it might be giving me an answer for each child, whether or not it was updated. But the number of responses is not matching the number of children, so don't think that is it either.

Anyone know what the second value being returned is? And if there is a way to get the path of the child updated?

I think the documentaiton might be out of date here. Any help would be appreciated.

Moon Wizard
September 14th, 2020, 16:41
The documentation for DB.addHandler was incorrect; and I updated the name of the second parameter. Please look at databasenode.onChildUpdate for more detail.

The second parameter basically is just a boolean indicator whether the list of children changed or not. (i.e. children added/deleted)

Regards,
JPG

MadNomadGM
September 14th, 2020, 18:03
The documentation for DB.addHandler was incorrect; and I updated the name of the second parameter. Please look at databasenode.onChildUpdate for more detail.

The second parameter basically is just a boolean indicator whether the list of children changed or not. (i.e. children added/deleted)

Regards,
JPG

Thanks for the quick response. Much appreciated.