Closed jakearchibald closed 1 year ago
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 https://github.com/w3c/ServiceWorker/issues/1373#issuecomment-451436409, which also put the API on the install event
The differences are:
registerRouter
to install all rules at once. The method can be called at most once in the install handler.add
and get
because registerRouter
covers them.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.
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.
There is a discussion on allowing the registration called multiple times in https://github.com/w3c/ServiceWorker/issues/1373#issuecomment-1667123029. Let me continue the discussion there. Other than that, I think the issue has been resolved.
I don't understand how this is different to my proposal, which also put the API on the install event, and:
In your proposal, when are the routes set?