Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Stop using document.removeEventListener() 😤

68,287 Aufrufe • vor 1 Jahr •via X (Twitter)

11 Kommentare

Profilbild von Ben Holmes
Ben Holmesvor 1 Jahr

Thanks for the tip @mattpocockuk

Profilbild von PDF GPT
PDF GPTvor 1 Jahr

This is my favorite AI tool for reviewing reports. Just upload a report, ask for a summary, and get one in seconds. It's like ChatGPT, but built for documents. Try it for free.

Profilbild von Alex MacArthur
Alex MacArthurvor 1 Jahr

You can use the same signal to nuke multiple listeners at once too!

Profilbild von samuel 🦋
samuel 🦋vor 1 Jahr

holy shit thank you for this

Profilbild von José Breijo
José Breijovor 1 Jahr

With `removeEventListener`, your codebase has a predictable 1:1 explicit relationship. It is declarative, and that is what it was intended for. Instead, an abortable signal is an optional argument; you need to carry it around, too, and manually kill listeners (malloc PTSD). Fashionable or more terse approaches are cool, but they are not always justified, at least not for me, like lambdas vs. function declarations.

Profilbild von Mantas
Mantasvor 1 Jahr

I don't know why, but this looks cleaner. Probably because event is removed in same way how it was added, not using some separate abortController object which is then passed as param to addEventListener...

Profilbild von JLarky
JLarkyvor 1 Jahr

The poor whiteboard got out of the frame :-(

Profilbild von Marius Vatasoiu
Marius Vatasoiuvor 1 Jahr

All good and then you find out you need to support Safari 14 💀

Profilbild von Iván Tajes Vidal
Iván Tajes Vidalvor 1 Jahr

Just stop using React!

Profilbild von Aaron
Aaronvor 1 Jahr

I wouldn't say "Stop using", instead, "here's another way to achieve a slightly similar effect but not exactly the same that may or not may not suite your use case" although where's the twitter friendly way on how to communicate that :p

Profilbild von Moshe Schnitzler
Moshe Schnitzlervor 1 Jahr

Practically speaking, how can pass in a AbortListener to clean my dishes?

Ähnliche Videos

Stop Dating Toxic Men!! 😤😤😤😡
0:29

Sensitive content

Stop Dating Toxic Men!! 😤😤😤😡

Patience

194,518 Aufrufe • vor 3 Monaten