Hello everyone,
I have a question regarding the cleanup of event listeners mentioned in your official documentation.
In the “Cleaning Up Listeners” section of your documentation, it is stated that listeners are not automatically cleaned up when a component is deleted and that this cleanup must be done manually. The documentation provides a script (cleanup.ts
) to assist with this process.
Link: Events | 8th Wall
However, while reviewing your example code and sample scripts, particularly in the state machine definitions using.onEvent(), I noticed there is no explicit handling for cleaning up listeners registered through .onEvent(). For instance:
.onEvent('gameOver', 'afterGame', {target: world.events.globalId})
Do I need to manually clean up ‘gameOver’? Or has the system cleaned that up automatically?
I want to ask whether it is necessary to manually clean up listeners registered with .onEvent()
when they are no longer needed. If so, what is the recommended way to handle this cleanup within the context of a state machine without violating the principles of using the ECS library?
I would greatly appreciate any clarification or guidance you can provide on this matter.
Thank you very much for your support and assistance!
Best regards,