question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.off behaves incorrectly

See original GitHub issue

Test case:

const emitter = dush()

const handler1 = () => { console.log('a') }
const handler2 = () => { console.log('a') }

emitter.on('a', handler1)
emitter.on('a', handler2)
emitter.off('a', handler1)

What is expected?

handler2 should not be removed

What is actually happening?

handler2 is removed because the lib uses fn.toString() to identify a function and source code of both functions looks the same

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tunnckoCorecommented, Nov 14, 2018

My solution stores a reference to the original handler in the wrapper rather than a string.

I was using this before ;d

But anyway I’m not hard about that, so PR is welcome.

(Oh, I should definitely update the repo boilerplate and stuff (oh god, there’s no automatic publish and release here?! so it’s really old of haha) ;d But if you are okey with that, great!)

0reactions
tunnckoCorecommented, Apr 26, 2020

@kouts, sorry, not for now. I can come back in few days and look into an update. I’m switching and upgrading machines now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

behave incorrect or behave incorrectly? - TextRanch
Title: CGIRequestHandler behave incorrectly with query component consisting mutliple ? Type: behavior, Stage: resolved. Components: Library .
Read more >
definition of misbehaves by The Free Dictionary
To behave badly. v. tr. To behave in an inappropriate way: The children misbehaved themselves at... ... 2. to conduct (oneself) badly or...
Read more >
How to Handle a Coworker's Bad Behavior the Right Way
“You're going in asking for their advice, as opposed to pointing out what they're doing wrong.” First: Go to your co-worker and frame...
Read more >
Handling Bad Behavior in Public Places: Alternatives…
Six times out of ten, that works; he becomes better behaved. This method takes longer, needless to say, than something like the shoulder...
Read more >
How to correct children's bad behavior - YouTube
Punishments don't address the root of the problem --what you want your ... When your child understands what they are to get out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found