-
While diving into the codebase I had the following questions (see inlined comments): Service worker registrationWhy do we try to update right after registering the service worker? Upon SW registration, why are we holidng off resolving this async function with another promise that resolves if an update has been found? HeliaServiceWorkerCommsChannelWhat's the use-case for EMITTER_ONLY? I couldn't find (not sure if it's me, but I found the HeliaServiceWorkerCommsChannel to be rather hard to understand due to all of the abstractions there, maybe I'm missing something but I couldn't figure it out from reading the code) ConfigurationHow was the config for this designed? (I failed to deduce the intricacies here by reading the code.)
For example, the config component calls both |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@2color lots here, but I will try to address 1:1 Service worker registration
IIRC, this is mostly to help with hot-reloading during development, making sure that changes are fully brought into the ServiceWorker. Also, this is a naive way to make sure we don't run into problems where folks are running the old version of the service worker across deployments. We may not need this, but during dev and initial build up, was easier to add and keep than remove and risk issues. This shouldn't have any visible impact in prod, but it could probably use some optimizations and ensuring we're following service worker best practices here. https://stackoverflow.com/questions/57916788/how-to-update-service-workers has some info about troubles with getting SW updates in comments
this could definitely be improved, no reason for this, but I didn't target optimizations here because it should be an easy thing to target at any time. HeliaServiceWorkerCommsChannel
This used to be used in the first iteration of helia-service-worker-gateway when we were logging work done in the service worker to the UI. The idea was to explicitly set up a comm for emitting events to others, so when reading the code you would know that channel shouldn't be used for listening. likely not needed any more.
Ideally, It would be good to reduce this down to a more targeted impl now that most of the message passing logic we need (famous last words) is implemented. Configuration
The design was mostly documented at #22, but it's not a fully fleshed out design by any means. More below:
We have to load the config in an iframe in order to have subdomains be able to read the config from the root domain. I don't know of any other way to pass logic between them without cookies or a backend. We don't want cookies for reasons discussed in #22 and no backend because many reasons :).
Mostly because writing inputs in forms to localStorage was what I was originally using. We could migrate the input components to write directly to the indexedDB. I would be open to that change if the UX doesn't decline and the code is simpler to maintain!
I think i missed removing the "loadConfigFromLocalStorage" in a spot :). Ideally, I was thinking the flow should work like this:
I believe 3.4 may no longer be needed because I hope that helps! Thanks for taking a peek and asking such clear questions |
Beta Was this translation helpful? Give feedback.
@2color lots here, but I will try to address 1:1
Service worker registration
IIRC, this is mostly to help with hot-reloading during development, making sure that changes are fully brought into the ServiceWorker. Also, this is a naive way to make sure we don't run into problems where folks are running the old version of the service worker across deployments. We may not need this, but during dev and initial build up, was easier to add and keep than remove and risk issues. This shouldn't have any visible impact in prod, but it could probably use some optimizations and ensuring we're following service worker best practices …