There is a much better way to handle custom events.
#JavaScript #TypeScript #WebDev
1/5
There is a much better way to handle custom events.
#JavaScript #TypeScript #WebDev
1/5
For years, developers used CustomEvent to pass data.
You must always wrap your data inside a detail property.
You cannot access your values directly.
It is also hard to type properly in TypeScript.
2/5
For years, developers used CustomEvent to pass data.
You must always wrap your data inside a detail property.
You cannot access your values directly.
It is also hard to type properly in TypeScript.
2/5
It makes your codebase easier to maintain.
Do you still use CustomEvent?
Or have you already switched to extending Event?
5/5
It makes your codebase easier to maintain.
Do you still use CustomEvent?
Or have you already switched to extending Event?
5/5
developer.mozilla.org/en-US/docs/W...
developer.mozilla.org/en-US/docs/W...
CustomEventで引数が使えるようになり
CyanTriggerが壊れた
CustomEventで引数が使えるようになり
CyanTriggerが壊れた
なので再レンダリングの代わりに親がupdateしたことを伝えるCustomEventをdispatchするようにしたらいいのではないかと思った
具体的にはこんな感じ
メリットとして全ての処理が1つのイベントの中に集約され、不要な再レンダリングが起きないようになる
なので再レンダリングの代わりに親がupdateしたことを伝えるCustomEventをdispatchするようにしたらいいのではないかと思った
具体的にはこんな感じ
メリットとして全ての処理が1つのイベントの中に集約され、不要な再レンダリングが起きないようになる
CustomEvent is *criminally* under-utilized
developer.mozilla.org/en-US/docs/W...
CustomEvent is *criminally* under-utilized
developer.mozilla.org/en-US/docs/W...
#Pride365 #MoreThanAGame #LGBT #LGBTQIA+ #Autism #AutismCommunity #AutismServer #mc #minecraft #minecraftEvent #minecraftResourcePack #CustomEvent #showcase
www.youtube.com/shorts/cZBkq...
#Pride365 #MoreThanAGame #LGBT #LGBTQIA+ #Autism #AutismCommunity #AutismServer #mc #minecraft #minecraftEvent #minecraftResourcePack #CustomEvent #showcase
www.youtube.com/shorts/cZBkq...
ᴛʜɪꜱ.ᴏɴᴄʟɪᴄᴋ = (ᴇᴠᴛ) => ᴅɪꜱᴘᴀᴛᴄʜᴇᴠᴇɴᴛ(
ɴᴇᴡ ᴄᴜꜱᴛᴏᴍᴇᴠᴇɴᴛ( ᴛʜɪꜱ.ɪꜱ ) ,
{ ʙᴜʙʙʟᴇꜱ: ᴛʀᴜᴇ, ᴄᴏᴍᴘᴏꜱᴇᴅ: ᴛʀᴜᴇ }
);
Keeps everything you need in one place/WebComponent
ᴛʜɪꜱ.ᴏɴᴄʟɪᴄᴋ = (ᴇᴠᴛ) => ᴅɪꜱᴘᴀᴛᴄʜᴇᴠᴇɴᴛ(
ɴᴇᴡ ᴄᴜꜱᴛᴏᴍᴇᴠᴇɴᴛ( ᴛʜɪꜱ.ɪꜱ ) ,
{ ʙᴜʙʙʟᴇꜱ: ᴛʀᴜᴇ, ᴄᴏᴍᴘᴏꜱᴇᴅ: ᴛʀᴜᴇ }
);
Keeps everything you need in one place/WebComponent
1. I think CustomEvent tends to be the most common and is still a viable option
2. Teams may want to switch to subclassing, but may not be in a position to introduce breaking changes, but can update the types
1. I think CustomEvent tends to be the most common and is still a viable option
2. Teams may want to switch to subclassing, but may not be in a position to introduce breaking changes, but can update the types
10/10 I've done it, works brilliantly. It's scalable, very focused, and no real 'catch' as the DX is quite nice with CustomEvent layered on top too.
10/10 I've done it, works brilliantly. It's scalable, very focused, and no real 'catch' as the DX is quite nice with CustomEvent layered on top too.
By: Chris Coyier on Thursday, November 20, 2025
By: Chris Coyier on Thursday, November 20, 2025
Bufferの`base64`と`base64url`のパフォーマンス改善、`CustomEvent`と`node --watch`をStableに変更、`fs/promises`のスタックトレースの追加など "Node.js — Node v20.13.0 (LTS)" https://nodejs.org/en/blog/release/v20.13.0 #nodejs #ReleaseNote
Bufferの`base64`と`base64url`のパフォーマンス改善、`CustomEvent`と`node --watch`をStableに変更、`fs/promises`のスタックトレースの追加など "Node.js — Node v20.13.0 (LTS)" https://nodejs.org/en/blog/release/v20.13.0 #nodejs #ReleaseNote
EventTargetとCustomEventを使ったPubSub/Observerパターン、Proxyを使ったリフアクティブなオブジェクト、Signal。
またDOMの`MutationObserver`や`IntersectionObserver`などAPIについて "Patterns for Reactivi…" https://frontendmasters.com/blog/vanilla-javascript-reactivity/
EventTargetとCustomEventを使ったPubSub/Observerパターン、Proxyを使ったリフアクティブなオブジェクト、Signal。
またDOMの`MutationObserver`や`IntersectionObserver`などAPIについて "Patterns for Reactivi…" https://frontendmasters.com/blog/vanilla-javascript-reactivity/