GwtMaterialDesign / gwt-material

A Google Material Design wrapper for GWT

Home Page:https://gwtmaterialdesign.github.io/gmd-core-demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ServiceWorker observing lifecycle not working as expected

ingosch opened this issue · comments

Sry, forget my initial post, my configuration was somehow messed up. But while testing and digging into serviceworkers I discovered some other issues with the ServiceWorkerManager that I don't understand.

protected void observeLifecycle(ServiceWorkerRegistration registration) {
        registration.onupdatefound = event -> {

            onNewServiceWorkerFound(new ServiceEvent(), registration.waiting);

            if (registration.installing != null) {
                onInstalling(new ServiceEvent());

                onStateChange(registration.installing);
            }

            if (registration.active != null) {
                onStateChange(registration.active);
            }
            return true;
        };
    }
  1. When reloading the page a servicworker that is waiting to be activated is ignored cause onupdatefound is not triggered in this case.
  2. Does calling onNewServiceWorkerFound with registration.waiting make sense? At that point there should usually be either no waiting SW or an older one that is to be replaced with the new one that triggered the onupdatefound event. IMHO the way it is at the moment onupdatefound will always be called together with onInstalling what is unnecessary.

I think using onupdatefound like it was until v2.2 (just calling it once on setup if registration.waiting is true) would make more sense and would solve problem nr. 1.