Open LeaVerou opened 7 months ago
That's correct. And the state transition and event are to be coupled together in a single task. You don't want to have one task updating the state and another firing the event.
Discussed today in a breakout with @plinss:
There are two components to this:
change
over update
)The first seems quite straightforward: change
is definitely the de facto standard in the Web Platform right now, with timeupdate
and compositionupdate
being the outliers. Are there reasons these were not named timechange
and compositionchange
? If so, we should encode those reasons in the naming guidance. If not, we should list them as antipatterns.
The second also seems uncontroversial, but until the requesters reply in https://github.com/w3ctag/design-reviews/issues/843 it's unclear if there has ever been an offender to this, in either an existing technology, a proposed one, or even a (popular) authorland one. If there is no example of anyone getting this wrong, I question the value of spending time writing it, though @plinss and I could not reach consensus about whether that means deprioritizing it or closing it altogether.
So to sum up:
I think it's worth drawing a more explicit line between https://w3ctag.github.io/design-principles/#js-rtc and https://w3ctag.github.io/design-principles/#event-design. Even if there's no known offenders, there's quite a few people struggling with the event loop.
This was brought up in our discussion of https://github.com/w3ctag/design-reviews/issues/843
It started as a naming observation:
change
is far more common thanupdate
in event names. Then we realized thatupdate
may be more appropriate when the event invocation happens regardless of actual state change. However, that does not seem to be followed by the web platform, e.g. reading the MDN docs ontimeupdate
, it sounds like it would only fire when the time has actually updated.Regardless, events that fire when things have not actually changed should be an antipattern. This is basically polling in disguise: the whole architectural reason to use events is that they fire during state transitions. Not only is this wasteful, it’s unclear whether there is an actual benefit to it (compared to only firing the event when there is a state transition).