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

Can promises be used for one-time events that may never occur? #73

Open
kainino0x opened this issue Apr 3, 2023 · 1 comment
Open

Comments

@kainino0x
Copy link

The One-time "events" section describes the use of Promises for one-time events. Is it acceptable to use for events that may never occur? For example, disconnection of a connection with an indefinite lifetime where reconnection isn't possible (e.g. a connection over a network or to a GPU or other hardware device).

I've gotten guidance from several sources in the past that this is an acceptable use of Promises, hence we used it in WebGPU, but it would be good to have guidance in this document. I'm not aware of usages of this pattern outside of WebGPU GPUDevice.lost, only of examples like ServiceWorkerContainer.ready. Are there any?

@domenic
Copy link
Member

domenic commented Apr 4, 2023

This seems fine to me.

Arguably cases like readableStreamReader.closed are like this because there's no guarantee that the stream will ever close or error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants