ember-responds-to icon indicating copy to clipboard operation
ember-responds-to copied to clipboard

Add an option to remove listener

Open hakubo opened this issue 7 years ago • 5 comments

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 avatar Feb 22 '18 08:02 hakubo

@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.

RobbieTheWagner avatar Feb 22 '18 14:02 RobbieTheWagner

yes, we do have a use case where we want to remove an event listener before that.

PS. Thanks for an awesome addon!

hakubo avatar Feb 23 '18 14:02 hakubo

@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.

RobbieTheWagner avatar Feb 24 '18 04:02 RobbieTheWagner

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 avatar Feb 26 '18 15:02 hakubo

@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.

RobbieTheWagner avatar Feb 26 '18 16:02 RobbieTheWagner