正在加载视频...

视频加载失败

Stop using document.removeEventListener() 😤

68,287 次观看 • 1 年前 •via X (Twitter)

11 条评论

Ben Holmes 的头像
Ben Holmes1 年前

Thanks for the tip @mattpocockuk

PDF GPT 的头像
PDF GPT1 年前

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.

Alex MacArthur 的头像
Alex MacArthur1 年前

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

samuel 🦋 的头像
samuel 🦋1 年前

holy shit thank you for this

José Breijo 的头像
José Breijo1 年前

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.

Mantas 的头像
Mantas1 年前

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

JLarky 的头像
JLarky1 年前

The poor whiteboard got out of the frame :-(

Marius Vatasoiu 的头像
Marius Vatasoiu1 年前

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

Iván Tajes Vidal 的头像
Iván Tajes Vidal1 年前

Just stop using React!

Aaron 的头像
Aaron1 年前

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

Moshe Schnitzler 的头像
Moshe Schnitzler1 年前

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

相关视频

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

Sensitive content

Stop Dating Toxic Men!! 😤😤😤😡

Patience

194,545 次观看 • 3 个月前