-
Notifications
You must be signed in to change notification settings - Fork 313
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
Allowing multiple scopes (& should scopes be primary key?) #566
Comments
Meeting summary:
|
@slightlyoff are you agreed on having a way to move scopes during activation? Am I right in thinking you want further evidence on the need for multiple scopes? |
@jakearchibald changing scope during activation would allow also to set the scope to a parent path or it will still be forbidden? |
Yes, agreed to API for moving scopes during activation. Also correct that we don't yet have a compelling example that demands multiple scopes and that examples along those lines would help convince me of the need. |
It seems to me this goal can already be mostly met by the UA optimizing around the |
If the SW has terminated, and an event needs to fire within the SW, the SW should only spin up if an event listener of that type was added last time the SW started. Does that work? @annevk, how do you feel about that? |
This would break cases where listener adding wasn't consistent, such as adding depending on |
Yea, I think this falls in the same bucket as async importScripts(), saving state on the global, etc. Its not going to work consistently and should be discouraged in SW scripts. |
I think an explicit switch would be way better than anything that requires observing whether or not there is an event listener added. |
I feel that this issue and others like issue #1026 or issue #1272 and the long-thought-after static routes are similar in that they are about refining if/how a Service Worker gets involved. I know that there is strong interest on those issues, including from Google and Facebook. I'm wondering if we can identify a path forward. So, here is my modest contribution to the discussion. Currently, we can only define that a Service Worker gets involved for a navigation to anything below its scope (prefix match) on a given origin. I've heard about the following use cases:
Use case 1 Use cases 2, 3 and 4 It seems:
For comparison, if we were to do these refinements as part of the register call, then it seems harder for a developer to reason about why the call failed, or separate the critical from the optional, etc. Now, I'm not saying that the methods have to be identical - they accept different things after all - but having a similar feel should be possible and welcomed. e.g. re-use the strict match vs. prefix option, parallelism of method names (addScope, addRoute), etc. Also, while addressing use case Nb 4 would also cover use case Nb 2, I think we should be able to proceed with an MVP for Nb 2 while keeping in mind the generic use cases in Nb 4. Handling scope conflicts
Does this sound reasonable? |
Presumably you can have multiple secondary scopes and only one primary scope per service worker? |
Yes. One primary, multiple secondaries. |
This is boiling down the discussions from #445 & meetings into a few options.
The goals
//docs.google.com/spreadsheets/d/docid
and//docs.google.com/a/mozilla.com/spreadsheets/d/docid
Proposal 1
reg.name
never changes & is the "primary key" of the registrationProposal 2
As proposal 1, except scope defaults to
/
. Scope can still be set tonull
or an empty array to opt out of fetch events.reg.name
never changes & is the "primary key" of the registrationProposal 3
reg.scope
(no longer appropriate for sync access, I think)Summary
name
property for identifying registrationsAll proposals allow changing scope, multiple scopes, and no scopes.
The text was updated successfully, but these errors were encountered: