-
Notifications
You must be signed in to change notification settings - Fork 831
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
Proposal: workbox-messages module #1848
Comments
This proposal sounds great to me. And I think it definitely makes sense for the message registrations to be handled by the individual packages, not all grouped in
|
As for the format, I think something like this would be fine: {
type: 'SKIP_WAITING',
meta: 'workbox-package-name',
} We could potentially also try to standardize on using verbs for action messages and nouns for notice message, or something like that. I believe right now our only message instances are: {
type: 'WINDOW_READY',
meta: 'workbox-window',
// payload: void
} {
type: 'CACHE_UPDATED',
meta: 'workbox-broadcast-cache-update',
payload: {
cacheName: 'the-cache-name',
updatedURL: 'https://example.com/',
},
} Am I missing anything? |
Oh, yeah, I forgot that adding in a |
I did a quick prototype and it looks like adding in this functionality would take This logic could live in a new |
In the CDN case, yes, but in the modules case it would only be loaded if a module that consumed it were loaded. This is also true of things like the IDB wrapper, which currently gets loaded for CDN users even if they're only using precaching (or any other module that doesn't use IDB). My preference would be to keep |
Moving over some thoughts from a separate conversation: if we had this module, it would be a good home for code that currently lives in workbox/packages/workbox-broadcast-cache-update/BroadcastCacheUpdate.mjs Lines 91 to 127 in 208850c
|
Yesterday I discovered that the SW spec includes a buffering mechanism (client message queue) for when a SW calls Unfortunately, this behavior isn't yet implement in all browsers, so for the moment we'll have to continue using this However, the buffering behavior applies to |
Hi there, Workbox is moving to a new engineering team within Google. As part of this move, we're declaring a partial bug bankruptcy to allow the new team to start fresh. We realize this isn't optimal, but realistically, this is the only way we see it working. For transparency, here're the criteria we applied:
Thanks, and we hope for your understanding! |
To accompany the new
workbox-window
library in v4, and standardize the functionality that's needed for theskipWaiting
message handler proposed in #1753 as well as what's already implemented inworkbox/packages/workbox-broadcast-cache-update/BroadcastCacheUpdate.mjs
Lines 185 to 207 in 208850c
I'm proposing a new set of methods on
workbox.core
:registerMessageCallback({messageType, callback})
will take care of adding in amessage
event handler (if one doesn't already exist) that will in turn check for incomingmessage
s whoseevent.data.type === messageType
, and when found, runawait callback(event)
for each registered event. The callback mechanism will be wrapped inevent.waitUntil()
(for browsers that support it: MessageEvent within the SW global should have waitUntil() w3c/ServiceWorker#669 (comment))unregisterMessageCallback({messageType, callback})
will do the opposite, and either unregister a specificcallback
, or ifcallback
isnull
, unregister all callbacks for the givenmessageType
.I think that keeping track of
messageType
values can be done on a per-module basis, i.e. the constant used byworkbox-broadcast-cache-update
can be defined locally there.One additional area for discussion is whether this proposal can end up powering the mechanism that's already in place in
workbox.core
for registering callbacks that can be run when there's a globalQUOTA_EXCEEDED
error. There's a lot of similarities, but invoking callbacks triggered by an exception is different from invoking callbacks triggered by amessage
event.The text was updated successfully, but these errors were encountered: