FG Spreadshirt Swag
  1. #1
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    253

    How to get change event in a different node on DB

    This time I have a problem that I don't know if it's fixable.

    I have a list of skills with the window that manages them, everything works fine. Then I have another window
    where I manage skill groups. In this one I have a windowlist that allows me to add or remove skills from the
    group. Here, too, everything works fine.

    In the first window, those of the skills, I added a windowlist that allows me to see which groups the skill is in.
    A function when loading (or when refreshing the window) scrolls the groups adding those in which the skill is
    present. This works well too.

    The problem I want to solve consists in real-time updating of the list in the skill window, i.e. I would like to see
    the group list updated if I have the single skill window open and add this to one or more groups or remove it
    from these.

    Is there any way to do this? I should go and check if something has changed in a tag of the DB that is not
    exactly that of the skill. Can I "register" to receive the change event of something within a different DB node?
    Last edited by Xarxus; December 17th, 2022 at 15:38.
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  2. #2
    You can register a change event.
    DB.addHandler([node/path], "onUpdate", [callback_function]);

    https://fantasygroundsunity.atlassia.../DB#addHandler

    Regards,
    JPG

  3. #3
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    253
    That's what I was needing! Ty.

    Will onUpdate catch everything inside the node? Also additions and/or deletions? Even the children?
    Or do I need to implement onAdd and onDelete as well, maybe even in the child version?
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  4. #4
    No, “onUpdate” is only to capture value changes on data nodes (string, number, etc).

    The onChildAdded, onChildUpdate, and onChildDeleted events are for direct child change tracking.

    JPG

  5. #5
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    253
    I've done some experimenting and it seems I can use onChildUpdate because it seems to be invoked even when adding or deleting items.
    A thousand thanks @Moon
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in