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

Describe waitUntil() behavior in terms of Promise.all() #738

Closed
nikhilm opened this issue Aug 21, 2015 · 3 comments
Closed

Describe waitUntil() behavior in terms of Promise.all() #738

nikhilm opened this issue Aug 21, 2015 · 3 comments
Milestone

Comments

@nikhilm
Copy link
Contributor

nikhilm commented Aug 21, 2015

It seems to me like waitUntil() can be significantly simplified if it uses Promise.all that is now in the ES spec.

While the event is dispatching (since waitUntil() can't be called when async), every promise passed to it is appended to an array. At the end of the dispatch wait on Promise.all(list of promises). That way we get 'rejection gets priority' for free.

@nikhilm
Copy link
Contributor Author

nikhilm commented Aug 21, 2015

The callsites at [[Install]] and [[Activate]] are sort of updated, but the description of waitUntil() could use some cleaning up.

@jungkees
Copy link
Collaborator

We're already using Promise.all() for waitUntil().

While the event is dispatching (since waitUntil() can't be called when async), every promise passed to it is appended to an array.

event object's extend lifetime promises is an array of promises to keep the list of the added promises.

At the end of the dispatch wait on Promise.all(list of promises). That way we get 'rejection gets priority' for free.

The task that runs the waitUntil() is actually doing this: "waiting for all of extendLifetimePromises settles."

It's sort of double-defined once in waitUntil()'s task algorithm's step 3 and Install algorithm step 11.5 and Active algorithm step 15.5.

May be we can try to simplify this bit by reducing one side of such steps, but on one hand I think it seems easier to understand the relationship of those algorithms as-is.

And waiting for all of, the algorithm description for Promise.all, is already giving us 'rejection gets priority' semantic as you pointed.

@slightlyoff slightlyoff added this to the Version 1 milestone Oct 28, 2015
@jakearchibald
Copy link
Contributor

Closing in favour of #771

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

No branches or pull requests

4 participants