in the last part of the video the event listener is set to once true but won't we need it later?

Kevin Powell
YouTube
I made a BIG mistake
I think it's important to highlight when we've made past mistakes and show the right way to do it when we find those mistakes. 🔗 Links ✅ The finished code: https://codepen.io/kevinpowell/pen/BaVdrLm ✅ More on Visually Hidden: https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html 📚 Resources I used to help make this video: ✅ AcceD...
10 Replies
Jochem
Jochem2y ago
it gets re-added every time the click handler runs on the close button closeMenu function runs
Aozen
AozenOP2y ago
okay but it gets removed then readded once right? once here does not mean only ever run once
13eck
13eck2y ago
once here means "this specific event listener is gone after it runs"
Jochem
Jochem2y ago
nope, the handler gets added every single time closeMenu runs, and runs once only and then removes itself again. Then, when closeMenu runs again, it gets re-added and runs once
13eck
13eck2y ago
And since it's being added each time the closeMenu() function is run, it'll happen once per close
Aozen
AozenOP2y ago
so it is removed from memory right?
13eck
13eck2y ago
indeed
Aozen
AozenOP2y ago
okay cool now i get it i was worried it would run once and only once XD till next refresh it reminds me of angular rx js is it similar in anyway by any chance?
13eck
13eck2y ago
Angular is JS so…yeah, it's probably very similar lol
Aozen
AozenOP2y ago
rxjs had like subscribe and unsubscribe anyway i leave that for another post thank you both for the answers ^^
Want results from more Discord servers?
Add your server