Mechanism of unregistering a custom event


Recently I’ve gone through the process of creating a custom event in Theia.

Things I understood and tried:

  1. Creating a custom event
  2. Registering it,
  3. Implemented the listeners for it.

But I’m not familiar how they’re disposed/unregistered. Requesting for the working process behind this.

@Abhay0294 thank you for the discussion, I assume you mean how the listeners are disposed, I’m not sure that use-case would require the event itself to be unregistered or removed. If you want to dispose a listener you simply need to call dispose on it.

For example. in the case of a Widget we create a DisposableCollection we push our listeners to, and this gets disposed when the widget is closed: