Starfinder Playlist
  1. #1

    What happens when "assinging" methods?

    In some places e.g. number_linked the following construct is used
    Code:
    node.onUpdate = someFunction
    Which executes the someFunction if the node is changed (or some other condition depending on what method is "assiniged").

    It looks like it is assinging and overriding an function for the node object. But since e.g. multiple number_linked work with the same databasenode it cannot be a simple override.
    It behaves more like DB.addHandler.

    Is this pattern a wrapper for DB.addHandler? If yes where does the handler get removed if the control is closed?

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,581
    Some background info here: https://fantasygroundsunity.atlassia...enode#onUpdate

    It's not exactly a wrapper for DB.addHandler, but it behaves similarly (in terms of running a function when a database node, or range of nodes in the case of DB.addHandler, is updated). DB.addHandler is not tied to an object and so any handlers that have been added need to be removed when the code scope is removed/destroyed to ensure there's no invalid functions trying to be called.

    <node>.onUpdate is tied to a specific database node object. So when that database node object is removed/destroyed then so is the handler.
    FG Con 16 Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Ok thank you so far.

    Is my assumption write that I can <node>.onUpdate = something multiples times and all "handlers" wil lbe called?

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,581
    Quote Originally Posted by Weltenbrand View Post
    Is my assumption write that I can <node>.onUpdate = something multiples times and all "handlers" wil lbe called?
    I'm not 100% sure, but I would guess no - as there's no way to remove previous onUpdate function assignments it would make sense if you could only have one and using <node>.onUpdate would override any previous assignment. If you want to call multiple handlers you could use different node objects variables - all attached to the same database path, but each a different variable. Or, probably a better idea, have a single event handler that calls different function if you need to have multiple functions.
    Last edited by Trenloe; October 12th, 2020 at 14:45.
    FG Con 16 Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

Thread Information

Users Browsing this Thread

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

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