Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32240

Re: remove listener

From Scott Sauyet <scott@sauyet.com>
Newsgroups comp.lang.javascript
Subject Re: remove listener
Date 2017-01-21 19:24 +0000
Organization A noiseless patient Spider
Message-ID <o60ci9$sl5$1@dont-email.me> (permalink)
References <_N2dnVScZPU0SR_FnZ2dnUU7-IXNnZ2d@westnet.com.au> <4137428.rnE6jSC6OK@PointedEars.de> <ebKdnbTeM4E0nB7FnZ2dnUU7-T3NnZ2d@westnet.com.au> <w8ydnVs1-tbith7FnZ2dnUU7-TXNnZ2d@westnet.com.au> <4v-dnTZ7z6m9rR7FnZ2dnUU7-K1j4p2d@westnet.com.au>

Show all headers | View raw


Andrew Poulos wrote:
> Andrew Poulos wrote:

>> How can I remove the listener if the handler is
>>   this.show.bind(this, i)
>> ?
> 
> My bad for wasting everyone's time. MDN tells me that bind creates a new
> bound function. 

That might be important to your overall use of the event listener, but it 
is not the crucial point in removing it.


> I just stored a reference to it and used that instead.

This is what's crucial.  And it is what Thomas Lahn was pointing out.  If 
you'd stored a reference to your original function, you could have 
removed it as well, regardless of whether you used `bind`.

  -- Scott

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 14:25 +1100
  Re: remove listener Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-21 06:07 +0100
    Re: remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 17:37 +1100
      Re: remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 20:35 +1100
        Re: remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 20:55 +1100
          Re: remove listener Scott Sauyet <scott@sauyet.com> - 2017-01-21 19:24 +0000
          Re: remove listener Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-23 20:14 +0100

csiph-web