Skip to content

[Feature]: 添加对事件监听器移除的支持 #285

@leoweyr

Description

@leoweyr

Is your feature request related to a problem? Please describe.

在现有的机制上,只允许添加事件监听器,而不能移除事件监听器(除非重启服务端)。如果一个事件监听器的设计是有生命寿命的,在超出生命寿命后它仍然继续执行虽然可以加层判断阻拦但是在 Ticks 中还是会有执行帧,多多少少会有性能上的消耗(特别是量大的情况下)。

Describe the solution you'd like

在底层上对 Levilamina 事件监听器进一步封装,在 LegacyScriptEngine 使用上,每次添加一个事件监听器返回一个事件监听器的对象,该事件监听器存在一个方法可以对内存中的事件监听器(自身)进行销毁移除,来实现对事件监听器的精细控制。

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions