Загрузка видео...

Не удалось загрузить видео

На главную

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?

Похожие видео