-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on()
collides with all sorts of code in the wild.
#39
Comments
Yup, that was my first reaction as well. I still like the |
That's very true. I personally don't care if it's @ming-codes: I'm not sure what you mean by |
Yes, |
Not my I original thought, but I like it. 😄 The Symbol could implement a function that returns an Observable.
|
Completely agree. Besides less possibilities of collissions, I think a method like |
I'd like to get a better feel for how much collision there might actually be in the wild. Are there huge libraries that supply a From looking at Cloudflare workers, they indeed support Anyways, some concrete examples of this being an issue would be very useful to see! |
Yeah, I think in-the-wild data from browser use counters would be necessary to believe there's some sort of unsolvable conflict here. |
I would prefer non-browser data be included as well from something like WinterCG or somewhere. Anything providing both EventTarget and EventEmitter interfaces (not inheritance) would be affected. |
At some point I can try and look into use counter data for Chromium, but since @bmeck filed this concern initially I'd love if you could take the first leap and help us track down this data from WinterCG or elsewhere, to try and substantiate the concern here. |
One slightly interesting conflict I encountered when implementing the I have no idea how common this kind of thing is in frameworks or user code. I'd certainly hope it's not common enough to preclude us from using what I think is a nice name like |
While I'm all in favor of short names, we have two decades of history where a function
Although the only hard namespace conflict is Prototype.js, choosing I hope it is still possible to use a more descriptive name like |
These are all really good examples, thanks a lot for providing them. They make a strong case for the theoretical problem of name collisions with new/confusing behavior under an old name ( This should give us a bunch of real-world data as to how suitable this API name is, before we ever launch the API to stable, giving us plenty of flexibility to change things up mid-trial. |
Note I was really concerned about breaking expecations, not about actual name collisions. The only name collision from the list above is Prototype.js (which patches Sorry that I couldn't make this clearer. |
No I think that was clear. I tried to capture that in:
but could've been clearer myself actually. |
Note that an origin trial won’t address or expose user confusion issues, since it simply won’t have anywhere near enough exposure to devs to provide that info. |
Hmm, I'm not sure. It's caught lots of things like this in the past. To say that it simply cannot provide a useful signal is to say the entire Origin Trial infrastructure is useless, which seems self-evidently false. |
@domfarolino to me it definitely seems like it would provide runtime usage feedback, and expose a subset of devs to it, but that subset won't likely ever be representative of devs as a whole - since aren't origin trials always run on a small number of partner corporate websites? |
Check out http://googlechrome.github.io/OriginTrials/developer-guide.html. Any site can opt-in to the Origin Trial. The maximum experiment population size is 0.5% of all page loads across Chrome. |
FWIW: This shouldn't break Prototype.js apps. Prototype will conflict with and overwrite it, but it won't break. They're creating a new Element class from the existing global element, then they're adding methods to it by trampling whatever is there (note the lack of the third argument for |
If we're doing all of this research on the name |
Dojo also uses /cc @dylans |
I found that when using Chrome 123 and setting The example itself runs fine, but when you close the floating "CodeGlass" dialog with the small X in the upper right corner, this error is shown in the console, and you can't reopen the example when you click the Run button again. |
|
|
How about something more explicit like |
I think |
They also won't share a common interface as these methods require different arguments. E.g. observing an |
|
There is |
jQuery does not patch In addition, |
Thank you for the discussion here. |
See the discussion in WICG/observable#39, which led to this decision. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1
Update, I've put an X poll out for this: https://x.com/domfarolino/status/1815458583334842691 to get a feel for how the community feels. |
I'm partial to I'd consider how it reads in composition like: element.when('mousedown')
.switchMap(start => document.when('mousemove')
.map(current => [
current.clientX - start.clientX,
current.clientY - start.clientY,
])
.takeUntil(document.when('mouseup'))
.subscribe() |
I would like to vote .listen() in that reply. |
I have the same feeling, but I feel like a noun like |
I'd still push on |
Sadly I think we have to call time of death on In the poll Now I'm trying to see if the thoughts in #72 will influence our decision at all. If we give |
I love the holistic thinking here. Let's make it a bit more concrete. If we used // (1)
imageElement.observe("load").subscribe(...);
ResizeObserver.observe(imageElement).subscribe(...); If we used // (2)
imageElement.observe("load").subscribe(...);
imageElement.observeResizes().subscribe(...); If we use // (3)
imageElement.when("load").subscribe(...);
ResizeObserver.observe(imageElement).subscribe(...); If we use // (4)
imageElement.when("load").subscribe(...);
imageElement.whenResized().subscribe(...); Overall I like (2) and (4) the most. It feels like a great unification of events and XObservers, where the XObservers just need slightly more specialized methods instead of the generic event-name-taking method. This also ties into the discussion in #72 about how maybe these methods might need to return subclasses. (1) is also reasonable, although it might be a bit confusing that the arguments to I think (3) feels bad, but concretely wouldn't be the worst thing. It just makes the APIs feel completely separate. Which, to be fair, they kind of are; they just share a return type. |
Of all the alternatives discussed, I'm +1 for |
See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1
I thought about this a bit more, and I think the visual symmetry of (1) is misleading. More generally, I think the symmetry of having a pre-existing It means:
That worries me, and pushes me to option (3) or (4) — Let's keep going with the It was out of hope for "sharing more stuff" that I mentioned an Observable-returning method on
... an argument I might extend, to apply to static methods too. That is, |
All of that is to say that at least on this thread, I think I feel settled on |
See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1
See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1
See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5730072 Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/main@{#1340875}
See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5730072 Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/main@{#1340875}
…get#when(), a=testonly Automatic update from web-platform-tests DOM: Rename EventTarget#on() to EventTarget#when() See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5730072 Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/main@{#1340875} -- wpt-commits: c4e3d193ad0d0e708ad2f252a245c368df098c6e wpt-pr: 47237
…get#when(), a=testonly Automatic update from web-platform-tests DOM: Rename EventTarget#on() to EventTarget#when() See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5730072 Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/main@{#1340875} -- wpt-commits: c4e3d193ad0d0e708ad2f252a245c368df098c6e wpt-pr: 47237
Thank you for considering these concerns ❤️ |
…get#when(), a=testonly Automatic update from web-platform-tests DOM: Rename EventTarget#on() to EventTarget#when() See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5730072 Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/main@{#1340875} -- wpt-commits: c4e3d193ad0d0e708ad2f252a245c368df098c6e wpt-pr: 47237
…get#when(), a=testonly Automatic update from web-platform-tests DOM: Rename EventTarget#on() to EventTarget#when() See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5730072 Reviewed-by: Joey Arhar <jarharchromium.org> Commit-Queue: Dominic Farolino <domchromium.org> Cr-Commit-Position: refs/heads/main{#1340875} -- wpt-commits: c4e3d193ad0d0e708ad2f252a245c368df098c6e wpt-pr: 47237 UltraBlame original commit: 635103775408664b51f70080db91b67ba60941b8
…get#when(), a=testonly Automatic update from web-platform-tests DOM: Rename EventTarget#on() to EventTarget#when() See the discussion in WICG/observable#39, which led to this decision, and WICG/observable#161 for the corresponding spec rename. R=jarhar Bug: 40282760 Change-Id: I9cd744460a3545c74fb34a0418c6ffddc5e6d4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5730072 Reviewed-by: Joey Arhar <jarharchromium.org> Commit-Queue: Dominic Farolino <domchromium.org> Cr-Commit-Position: refs/heads/main{#1340875} -- wpt-commits: c4e3d193ad0d0e708ad2f252a245c368df098c6e wpt-pr: 47237 UltraBlame original commit: 635103775408664b51f70080db91b67ba60941b8
Lots of libraries and runtimes use
on()
as a generic event handling mechanism. This name might cause problems for them updating and as such cause unnecessary friction. It would be good to see if there is another name that is less prevalent in the same design space that wouldn't collide with Cloudflare Workers, Bun, Node.js, etc. and the libraries written for them (Note: all of these have some form of EventTarget, but often mix with EventEmitter'son
in the wild or for backwards compatibility).The text was updated successfully, but these errors were encountered: