Page MenuHomeFeedback Tracker

Pass Event Handler handle as param
New, WishlistPublic

Description

handle = addEventHandler ["whatever",{}];

the handle is only known once EH is created and the code is sealed, so there is no way passing this to the code upon EH creating. The only way to use this is to store EH handle in a variable for later use.

Why not pass EH handle to the code upon EH triggering? Like you can pass action ID to action code in addAction? Would make it so much easier to remove them from their own code.

Thank you.

Details

Legacy ID
2082575656
Severity
None
Resolution
Open
Reproducibility
Always
Category
Feature Request

Event Timeline

Killzone_Kid edited Additional Information. (Show Details)
Killzone_Kid set Category to Feature Request.
Killzone_Kid set Reproducibility to Always.
Killzone_Kid set Severity to None.
Killzone_Kid set Resolution to Open.
Killzone_Kid set Legacy ID to 2082575656.May 7 2016, 5:26 PM
Bohemia added a subscriber: AD2001.Nov 18 2013, 1:51 PM

Well, doing that now would break everything, unless it's added to the end of the parameter list. Which would make it in the middle if new parameters were added to the EH.

What they could do is add an overload of the removeEventHandler that takes a code block. The code block that was used when the EH was added.

Eg.

myCallback =
{

player removeEventHandler ["Fired", myCallback];
hint "The player fired! Removing EH!";

}

player addEventHandler ["Fired", myCallback];

Adding new param at the end of param array is not tragic and won't break anything and allow for further expansion. I'd say this is another 5 min job with great outcome. Talking about costs vs benefits, this one is a definite winner.

EH handle could even be passed as a separate variable, not necessarily as part of _this array. Could be _id, to make it easy to copy paste update all event handlers.