When creating event handling I often had a class like: addTypeofEventHandler and a removeTypeofEventHandler and handlers may have labels/names to them that had to be passed.
More common in JS , (and later in development) the "remove" function is returned as part of the creation:
const removeListener = physicsSystem.addLoopListener(whateverFn);
removeListener();
This is a cleaner and more expected method and I think the way to go.
Another issue is the usage of "on" as in "onXYZ" vs "addXYZHandler" this is mostly a semantic issue.
Lastly, some functions, like "action" functions on the characterController class, are filter functions. The controller fires MANY actions, and it would be annoying to add handlers for every type.
Instead it uses the pattern onAction('actionLabel', handler) with the return being the remover.
When creating event handling I often had a class like:
addTypeofEventHandlerand aremoveTypeofEventHandlerand handlers may have labels/names to them that had to be passed.More common in JS , (and later in development) the "remove" function is returned as part of the creation:
This is a cleaner and more expected method and I think the way to go.
Another issue is the usage of "on" as in "onXYZ" vs "addXYZHandler" this is mostly a semantic issue.
Lastly, some functions, like "action" functions on the characterController class, are filter functions. The controller fires MANY actions, and it would be annoying to add handlers for every type.
Instead it uses the pattern
onAction('actionLabel', handler)with the return being the remover.