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

Issues with "Handle Functional Event" #1196

Open
jakearchibald opened this issue Sep 21, 2017 · 2 comments
Open

Issues with "Handle Functional Event" #1196

jakearchibald opened this issue Sep 21, 2017 · 2 comments

Comments

@jakearchibald
Copy link
Contributor

jakearchibald commented Sep 21, 2017

Sorry for the vague title, I couldn't explain it briefly.

https://w3c.github.io/ServiceWorker/#handle-functional-event.

"Handle Functional Event" wants an ExtendableEvent, a registration, and some callback steps. These callback steps are run on the active service worker's event loop. However, I need to be on the service worker's event loop in order to create the ExtendableEvent.

Maybe the algorithm should take the event name instead of an ExtendableEvent, and we just expect other specs to call "Update Service Worker Extended Events Set" themselves.

Also, it feels like "Update Service Worker Extended Events Set" only needs to take an ExtendableEvent, since the active worker could be determined from the global the ExtendableEvent was created in.

So other specs would do:

  1. Handle a functional event for registration and "eventName" using the following steps:
    1. Let event be a (…new event object).
    2. Dispatch event on the current global object.
    3. Update Service Worker Extended Events Set with event.
@jakearchibald
Copy link
Contributor Author

jakearchibald commented Sep 21, 2017

In fact, we could define "Dispatch a service worker event" which takes an ExtendableEvent, which also calls "Update Service Worker Extended Events Set".

So it'd become:

  1. Handle a functional event for registration and "eventName" using the following steps:
    1. Let event be a (…new event object).
    2. Dispatch a service worker event event.

@jungkees
Copy link
Collaborator

"Handle Functional Event" wants an ExtendableEvent, a registration, and some callback steps. These callback steps are run on the active service worker's event loop. However, I need to be on the service worker's event loop in order to create the ExtendableEvent.

Right. I checked two call sites, Notifications API and Push API. Notifications API was creating an event within the callbackSteps without giving an event argument to Handle Funcational Event. (So, the arguments and the algorithm input params needed to be clarified.) Push API was creating an event from the caller's steps. Yeah, so we need to clarify this. I left review comments in #1199.

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