-
Notifications
You must be signed in to change notification settings - Fork 90
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
Discussion: Add back an async subscription method? #49
Comments
It will be unfortunate if a |
I think async subscription is not intuitive for the general case. If I say "subscribe", I expect to receive any event which happens from the time "subscribe" returns onward. That's the crux of the EventTarget problem. In my opinion, this problem is general in scope: the issue will arise whenever we want to model events which are not buffered. The goal of avoiding zalgo is good, though, and we should take it seriously. Having two methods solves one problem, but it creates another: how is the non-expert developer supposed to know which is appropriate? The difference is too subtle, and I would rather this thing "just work" without having to explain such subtleties. The ideal, for me, is a universe where subscription is always sync, but observables never deliver data before "subscribe" has completed. That's why I have Unfortunately, I was unable to come up with an API which would elegantly enforce such a limitation. In the end, I was content with core API not enforcing any such restriction, and instead relying on best-practices to emerge among users (with the help of the good example set by Javascript is definitely missing an At the end of the day, the zalgo problem might not even matter that much. If observables are ultimately compatible with async iteration statements, then users can "subscribe" to an observable like this: for await (let x of someObservable) {
// Do whatever with `x`
} Since control flow doesn't get split into sync and async paths, there is no zalgo to worry about. |
Closing due to inactivity (and I'm still opposed to two subscription methods in the core proposal). |
Continuation of #38
From @jhusain
The text was updated successfully, but these errors were encountered: