Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Emitter#stopListening() and Emitter#off() improvements #145

Closed
wants to merge 3 commits into from
Closed

Conversation

scofalik
Copy link
Contributor

@scofalik scofalik commented Apr 7, 2017

Suggested merge commit message (convention)

Fix: utils.Emitter#off() called without arguments will stop executing all callbacks added by utils.Emitter#on(). Additionally, utils.Emitter#stopListening() called without arguments will also call utils.Emitter#off() thus stop all callbacks added by utils.Emitter#on(). Closes ckeditor/ckeditor5#4947.

…callbacks added by .on().

Changed: Emitter#stopListening() called without any parameters now also removes callbacks added by .on().
@Reinmar
Copy link
Member

Reinmar commented Apr 11, 2017

I pushed a couple of improvements, but unfortunately, I find this module too messy. We're just asking for troubles. You can even see that the currently implemented solution is a hack by how it stands out from the rest of the code: https://github.com/ckeditor/ckeditor5-utils/pull/145/files#diff-1b61a350b30716326bca3d6e478665d8R219

For me, this.on() must use this.listenTo( this, ... ). This may need some refactoring because today the on() method is the base one, while listenTo() uses it. For me, it should be the opposite.

I know that we could live with the proposed solution for months, but for me this is too important piece of the code to have any doubts about how it works. We can see that it already leaked and that all of us were surprised what happened (even though I found this in the past). So, since the entire editor bases on this mechanism I'm for keep it as clean as possible.

@Reinmar
Copy link
Member

Reinmar commented Apr 11, 2017

R-, but I'm open for discussion ofc :P

@scofalik
Copy link
Contributor Author

I, too, hate this whole mixin. But this PR blocks this: ckeditor/ckeditor5-engine#904 . Maybe we could refactor it in separate issue?

@Reinmar
Copy link
Member

Reinmar commented Apr 13, 2017

But this PR blocks this: ckeditor/ckeditor5-engine#904 . Maybe we could refactor it in separate issue?

This issue isn't critical so we're not in hurry. Having it open and having this one open will force us to get back to this topic sooner.

@scofalik
Copy link
Contributor Author

scofalik commented May 2, 2017

I've made some improvements on branch 144-b but they are not ready yet. I will be tinkering with this in "meantimes".

@Reinmar
Copy link
Member

Reinmar commented Nov 9, 2017

#190 replaces this PR so I'm closing this one.

@Reinmar Reinmar closed this Nov 9, 2017
@Reinmar Reinmar deleted the t/144 branch November 9, 2017 15:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should EmitterMixin.stopListening() off all listeners (those added through on() too)?
2 participants