Skip to content

Unsubscribe to all the listener #102

@chenxeed

Description

@chenxeed

Hello,

should there be a method to remove all listeners of the emitter, to save performance?

I have an example case when we initialize a component, and the component needs to use the event emitter, and pass it to other function to listen to the component event:

// component.js
componentInit() {
  method.init(emitter);
}

// method.js
init (emitter) {
  emitter.on('something', doSomething);
}

Then, when the component is about to be destroyed, should the emitter be "cleaned up" so the method won't have to preserve the event listener anymore? For ex:

// component.js
componentDestroy() {
  emitter.off('*');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions