-
Notifications
You must be signed in to change notification settings - Fork 165
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
Allow functions to be used as promise inputs #1020
Comments
Re: waiting for async-do: I am no longer confident I'll get async-do to stage 3 within the next ~6 months. I'm still holding out hope for within a year, though. (There's some irritating complexity in the design of do-expressions which is slowing it down, and unfortunately for personal reasons I haven't been able to dedicate as much time as I'd like for the past few months.) |
This would mean that something like It does seem useful as it's the kind of code you would expect to work, but I worry about the mismatch with JavaScript in general becoming a problem for developers as they would have to know about this and the difference between Web IDL and non-Web IDL APIs. |
So far the only promise-accepting APIs in JS are the promise combinators themselves, which I think should be exempt from this sort of special-casing. I do think if ES introduces new promise-accepting APIs (although it's hard to imagine what), they should follow the precedent we set here. |
What about a function object that has a |
It would be called; the |
That is the opposite of how |
Yes. That's fine. |
APIs that want this should just be able to use: callback PromiseCallback = Promise<undefined> ();
interface AppHistoryNavigateEvent : Event {
undefined transitionWhile((Promise<undefined> | PromiseCallback) newNavigationAction);
}; |
The idea is to do it uniformly for the entire web platform, not as one-offs. |
See WICG/navigation-api#40 for background.
Basically, any time we convert an ES value to a
Promise<T>
, we should first check to see if it's a function. If so, we should call the function, and use its return value.This allows code such as
to become
This would be backward-compatible since there is no existing instances of
Promise<T>
whereT
is a callback function type, that are used as inputs.The text was updated successfully, but these errors were encountered: