[HN Gopher] Events
___________________________________________________________________
Events
Author : aanthonymax
Score : 18 points
Date : 2025-08-10 20:22 UTC (2 hours ago)
(HTM) web link (developer.mozilla.org)
(TXT) w3m dump (developer.mozilla.org)
| aanthonymax wrote:
| Event capturing and bubbling and much more
| cranberryturkey wrote:
| MDN is the best.
| Waterluvian wrote:
| I often imagine _state_ and _events_ as the two impulses that
| drive an application. I like React a lot, but a common pitfall is
| that it is 95% focused on state, and so you get odd cases where
| you end up trying to encode events as state.
|
| You'll see this anywhere you see a usePrevious-like hook that you
| then use to determine if something changed and act on it (eg. I
| hold state that a robot is offline, but I want to do something
| special when a robot goes offline). This is inferring an event
| from state.
|
| I've had luck adding an event bus as a core driver of a complex
| react application for events I don't want to track as state. But
| it always feels that it's a bit in conflict with the state-driven
| nature of the application.
| h4ch1 wrote:
| Using Svelte and building global state classes with $state(),
| $effect() has really helped with managing side-effects and
| surgical updates without building a custom event system which has
| historically added unnecessary boilerplate to many of my projects
| with a frontend.
|
| Having components bound to or using any of the $states or
| $derived update automatically without having to manually register
| event listeners, firing events, etc.
|
| Used to dislike runes so much initially, but working a bit more
| deeply with them has really made me appreciate the API changes.
___________________________________________________________________
(page generated 2025-08-10 23:00 UTC)