ember-responds-to
ember-responds-to copied to clipboard
Add an option to remove listener
currently to remove e.g. scroll listener
one have to window.removeEventListener('scroll', this.scrollHandler);
this is using 'private' stuff of ember-responds-to
what do you think about adding an option to remove listeners e.g. this.removeScroll() etc -
@hakubo they are cleaned up on their own https://github.com/dollarshaveclub/ember-responds-to/blob/master/addon/mixins/responds-to-scroll.js#L28
Is there a need for removing before that? I'm a bit confused here.
yes, we do have a use case where we want to remove an event listener before that.
PS. Thanks for an awesome addon!
@hakubo do you have a suggestion on how we would have an API that was any cleaner than just using window.removeEventListener('scroll', this.scrollHandler);
? I'm not opposed to this, I'm just not sure on the use case here. If you can help me with how you are using this and how you'd like to remove the listener, we can probably provide it.
this.scrollHandler
- this is coming from an addon and might not be obvious at first sight what is happening there when you look into a component.
this.removeScrollListener(); this.addScrollListener();
could be more readable.
@hakubo If you just want to manually add and remove listeners, shouldn't that be out of the scope of this addon? This addon is made to wire these things up for you.