removeListener()
world.events.removeListener(target, name, listener)
Description
Un-registers an existing listener. The eid, name, and exact reference to the listener callback is needed to remove the listener.
Parameters
Property | Type | Description |
---|---|---|
target | eid | The eid of the entity that the listener is attached to. |
name | string | The name of the event that the entity is listening for. |
listener | function | The function that gets triggered when the event name is dispatched to the target entity or a entity that is a child of the entity the listener is attached to. |
Returns
None.
Example
const handleCollision = (e) => { console.log("I touched another entity") }
// This listener logs a message whenever the entity collides with another entity.
world.events.addListener(component.eid, ecs.physics.COLLISION_START_EVENT, handleCollision)
// This line removes the listener
world.events.removeListener(component.eid, ecs.physics.COLLISION_START_EVENT, handleCollision)