Giter VIP home page Giter VIP logo

Comments (1)

userquin avatar userquin commented on July 18, 2024

The service worker lifecycle is complex, we may have 2 service workers when new version detected.

Here is what I understand so far, and some related questions.

* isInstalled: true when PWA is installed on the device.

PWA installed, also TWA, but not all cases, check link in the template

* showInstallPrompt: _This seems to be a state, but what is impacting its value?

this flag is to call browser/native prompt: check https://elk.zone app on browser, right aside (next popup will be shown only when this flag is true)

imagen

* cancelInstall: _What does this method?_

this method only force to remove the custom install popup, it is the dismiss button in previous screenshot: once cancelInstall called showInstallPrompt will never be true again (will store false in local storage), sometimes ppl just want browser/native install behavior

if installation cancelled from browser/install prompt, showInstallPrompt will be activated when required

* install: Install the PWA. _What if called while already installed?_

nothing happens, the method is just Promise.resolve(): the plugin will change it when received beforeinstallprompt event

calling this method will just call browser/native install logic

* swActivated: state of the activation of the service worker.

will be true when the new/current sw is active: check the logic in the template, onRegisteredSW callback

* registrationError: indicate if an error occurred during SW registration. _How to get the error?_

not exposed: we can expose it in onRegistrationError (I need to check if we can access it from active sw)

* offlineReady: _What does it mean exactly? What is impacting its value?_

flag only fired in first sw install: you can use it to show your app is ready to work offline when using workbox precaching

* needRefresh: _What does it mean exactly? What is impacting its value?

this flag will be true when new sw detected and ready to be activated: only when using prompt register type

* updateServiceWorker: Method to update SW when an update is pending. _Is it related to needRefresh?

yes, once needRefresh is true, the UI should bind button click to this method to activate the new service worker (will claim all openened clients, tabs and browser instances, controlled by previous installed service worker)

* cancelPrompt: _What does this method? Is it related to cancelInstall?_

no, it is related to offlineReady and needRefresh: when new sw detected, the ui should show a prompt, this method will switch these 2 flags to false

* getSWRegistration: Get the SW registration.

from nuxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.