DICE PACKS BUNDLE
  1. #1

    Handler Questions

    Hello I have some questions on handlers (DB.addHandler).

    Is onChildUpdate recursive ?
    eg. does
    Code:
     DB.addHandler("rootnode", "onChildUpdate",doSomething)
    catch a change of rootnode.node.subnode ?

    Is there a performance difference between (in the case of many nodes):

    Code:
    DB.addHandler("rootnode.*", "onUpdate",doSomething)
    and
    Code:
    DB.addHandler("rootnode.node1", "onUpdate",doSomething)
    DB.addHandler("rootnode.node2", "onUpdate",doSomething)
    DB.addHandler("rootnode.node3", "onUpdate",doSomething)
    ....
    Does the wildcard(*) spans multiple subnode?
    e.g. does
    Code:
    DB.addHandler("rootnode.*.endnode", "onUpdate",doSomething)
    catch rootnode.node1.node2.node3.endnode ?

    Best Regards

  2. #2
    Quote Originally Posted by Weltenbrand View Post
    Hello I have some questions on handlers (DB.addHandler).

    Is onChildUpdate recursive ?
    eg. does
    Code:
     DB.addHandler("rootnode", "onChildUpdate",doSomething)
    catch a change of rootnode.node.subnode ?

    Is there a performance difference between (in the case of many nodes):

    Code:
    DB.addHandler("rootnode.*", "onUpdate",doSomething)
    and
    Code:
    DB.addHandler("rootnode.node1", "onUpdate",doSomething)
    DB.addHandler("rootnode.node2", "onUpdate",doSomething)
    DB.addHandler("rootnode.node3", "onUpdate",doSomething)
    ....
    Does the wildcard(*) spans multiple subnode?
    e.g. does
    Code:
    DB.addHandler("rootnode.*.endnode", "onUpdate",doSomething)
    catch rootnode.node1.node2.node3.endnode ?

    Best Regards
    There is no recursive to my knowledge (if this can be done then its news to me - maybe some dev can comment). You are defining an exact match (this can include a child node in which case its any of them), when changed it will trigger the call back. (FYI I only deal with FGU code)

    This is the doc for things directly usable in FG - for the rest you you should be referencing the rulesets or extension code (.pak, .ext which are just zip files) for examples.

    In the doc this is the description...

    addHandler

    function addHandler( nodepath, event, callback )
    Add an event handler callback function to a specified database event on any node matching the specified database path.

    The handler function should have the following signature: [function name]([parameters]). The parameters will vary depending on the database event the function is attached to, as follows.

    * [onAdd] parameters = (nodeAdded)

    * [onCategoryChange] parameters = (nodeChanged)

    * [onChildAdded] parameters = (nodeParent, nodeChildAdded)

    * [onChildCategoriesChange] parameters = (nodeParent)

    * [onChildDeleted] parameters = (nodeParent)

    * [onChildUpdate] parameters = (nodeParent, bListchanged)

    * [onDelete] parameters = (nodeToBeDeleted)

    * [onIntegrityChange] parameters = (nodeChanged)

    * [onUpdate] parameters = (nodeUpdated)

    Parameters

    nodepath (string)
    A data base path identifier. The '*' character can be used as a wildcard for a path segment.

    event (string)
    The event to be captured (onUpdate, onAdd, onDelete, onObserverUpdate, onChildAdded, onChildUpdate, onChildDeleted, onIntegrityChange)

    callback (function)
    The function to be called when the event triggers
    Last edited by SilentRuin; December 11th, 2020 at 15:45.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  3. #3
    Hi, thank you for your answer.
    But it does not adress my question, I have read the docs and other ruleset are not really an answer to this question.

    A "path segment" can contain multiple subpaths, depending on the implementation (which I dont know). I assume there are no recursive calls, but maybe the syntax is different (in some wildcard implementations some thing like /*/* would catch all subpaths).

  4. #4
    Quote Originally Posted by Weltenbrand View Post
    Hi, thank you for your answer.
    But it does not adress my question, I have read the docs and other ruleset are not really an answer to this question.

    A "path segment" can contain multiple subpaths, depending on the implementation (which I dont know). I assume there are no recursive calls, but maybe the syntax is different (in some wildcard implementations some thing like /*/* would catch all subpaths).
    If you read it then you read what I quoted you here...

    nodepath (string)
    A data base path identifier. The '*' character can be used as a wildcard for a path segment.


    If you looked through the 5E/CoreRPG rulesets as I described then a simple search for .*" would have shown you things like these...

    DB.addHandler("charsheet.*", "onAdd", addIdentity);
    DB.addHandler(DB.getPath(node, "effects.*"), "onChildUpdate", onEffectsUpdated);
    DB.addHandler(DB.getPath(node, "targets.*"), "onChildUpdate", onTargetsChanged);

    So if as you say you've already looked as I suggested - I'm not sure what questions you have left unless you need to try something nobody else has. Each trigger - as described in the document - will occur for a given node.

    An example out of my own extensions shows even further refinement of this...

    DB.addHandler("combattracker.list.*.inventorylist. *.carried", "onUpdate", onCarriedChanged);

    Maybe its the word "recursive" that is confusing things to me in your question - either way - if you've looked at all these already - I'm not sure how to answer your question. Maybe someone else can give it a shot as I don't know what more I can tell you that I've not told you already.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

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 Product Walkthrough Playlist

Log in

Log in