Re: [w3ctag/design-reviews] Observable API (Issue #902)

Hi @domfarolino,
  
We looked at this today during a breakout. We do have consensus on most of the concerns I expressed above, especially around standards venue.
  
Furthermore, we had some questions about the API shape that we couldn’t figure out from the explainer, and we were hoping you might be able to clarify.

It _seems_ (though we are not 100% certain) that this is a separate primitive than `EventTarget` and simply integrates with it. If that is correct, the current explainer is a little unclear on what the boundaries of each are. Does it use the same `Event` objects? Does it register event listeners behind the scenes? How does bubbling work? Does it support bubbling to parent objects when not using the `EventTarget` integration?
  
- All examples are about listening to predefined events on existing objects. How do authors create objects that can emit events? Today they need to extend `EventTarget` which is suboptimal. Does `Observable` enable a new pattern for this?
- Do you folks have any plans to integrate with any of the other pub/sub mechanisms on the web platform or JS runtimes? E.g. all the `*Observer` objects, or Node’s Event emitter?
- While the code examples are certainly succinct, we had trouble figuring out how many of them worked and extrapolate how to write code about use cases not listed in the explainer. We were especially unclear on the arguments of `subscribe()` (what does `next` do? How does it differ from `callback`?)
  
We think a reworking of the explainer would really help answer these types of questions. Some (non-exhaustive) suggestions:
- Start from use cases and user needs.
- Include some simple code examples before the more pragmatic ones, so the reader can understand how the primitives involved work
- Include code showing how authors can use this to enable their own objects to emit events.
- A clear separation of what is `Observable` and what is `EventTarget`.
  
----
  
@littledan @ljharb @ctcpip @robpalme We saw you folks upvoted my last comment. Has there been any recent discussion in TC39 around this? Any plans to discuss it in the upcoming Plenary?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/902#issuecomment-2186987106
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/902/2186987106@github.com>

Received on Monday, 24 June 2024 16:41:27 UTC