Skip to content
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

Add Observable API #2863

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Observable API #2863

wants to merge 1 commit into from

Conversation

foolip
Copy link
Collaborator

@foolip foolip commented Apr 10, 2025

No description provided.

@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label Apr 10, 2025
name: Observable
description: TODO
description: The `Observable` API provides a composable, ergonomic way of handling an asynchronous stream of events.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is directly from the spec, because I don't understand the API well enough to describe it myself.

@domfarolino how would you describe this to a web developer in more objective terms? In particular I think we shouldn't claim it's ergonomic here, that's up to developers to judge I think.

I'm thinking something like:

The Observable API allows you to subscribe to events in a new way. The when() method does something that is different than addEventListener().

Help? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention the when method earlier in the description.

Suggested change
description: The `Observable` API provides a composable, ergonomic way of handling an asynchronous stream of events.
description: The `when()` method of an `EventTarget` object, such as a DOM element, returns an `Observable` API instance which allows to ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Developers telling us it was ergonomic1 is what led me to ship the API and write the spec, so I feel like that description isn't a declaration as much as it is a response. But something like:

An Observable is an object representing a stream of events that you can operate on declaratively, even before it emits any events. `EventTarget#when()` returns an Observable that you can immediately subscribe to and direct with native operators, providing an ergonomic, composable alternative to `addEventListener()`.

Maybe something like that?

Footnotes

  1. In a way that Promise ergonomics compare to callbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature definition Creating or defining new features or groups of features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants