Skip to content

Install event usage #2

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

Closed
jakearchibald opened this issue Jun 11, 2023 · 3 comments
Closed

Install event usage #2

jakearchibald opened this issue Jun 11, 2023 · 3 comments

Comments

@jakearchibald
Copy link

Unlike Jake’s proposal, registerRouter() is a part of the install event for simplicity. When the install listener is executed, the routes are not set. Web developers can call registerRouter() to set routes at that time.

I don't understand how this is different to my proposal, which also put the API on the install event, and:

A service worker has routes. The routes do not belong to the registration, so a new empty service worker will have no defined routes, even if the previous service worker defined many.

In your proposal, when are the routes set?

@yoshisatoyanagisawa
Copy link
Collaborator

Thank you for the comment,

Unlike Jake’s proposal, registerRouter() is a part of the install event for simplicity. When the install listener is executed, the routes are not set. Web developers can call registerRouter() to set routes at that time.

I don't understand how this is different to w3c/ServiceWorker#1373 (comment), which also put the API on the install event

The differences are:

  • use registerRouter to install all rules at once. The method can be called at most once in the install handler.
  • omit add and get because registerRouter covers them.
  • omit register attribute because we only have registerRouter method in the router attribute.

I believe the capability of both approaches are the same, but I believe this proposal is easier to implement and easier for developers to understand the current rules.

And yes, adding them to the install event existed since your idea, I will update my proposal to clarify that.

(I noticed that I forgot to update the examples to the new syntax. Let me do that soon.)

A service worker has routes. The routes do not belong to the registration, so a new empty service worker will have no defined routes, even if the previous service worker defined many.

In your proposal, when are the routes set?

During the install event handler, which should be the same timing with your proposal.

@jakearchibald
Copy link
Author

That all sounds good to me! I got confused because it said "Unlike Jake’s proposal…" then described something pretty much the same as my proposal 😄

Making the router a single call is ok, it just might make error handling more difficult, since it's harder to tell which of your (eg) 20 routes contained the error.

@yoshisatoyanagisawa
Copy link
Collaborator

There is a discussion on allowing the registration called multiple times in w3c/ServiceWorker#1373 (comment). Let me continue the discussion there.
Other than that, I think the issue has been resolved.

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