-
-
Notifications
You must be signed in to change notification settings - Fork 62
Simplify Automatic Reload chapter #180
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,17 +6,18 @@ outline: deep | |
| # Automatic reload | ||
|
|
||
| With this behavior, once the browser detects a new version of your application, then, it will update the caches and will reload any browser windows/tabs with the application opened automatically to take the control. | ||
|
|
||
| ::: warning | ||
| In order to reload all client tab/window, you will need to import any virtual module provided by the plugin: if you're not using any virtual, there is no way to interact with the application ui, and so, any client tab/window will not be reloaded (the old service worker will be still controlling the application). | ||
|
|
||
| Automatic reload is not automatic page reload, you will need to use the following code in your application entry point if you want **automatic page reload**: | ||
| You will need to use the following code in your application entry point: | ||
|
|
||
| ```js | ||
| import { registerSW } from 'virtual:pwa-register' | ||
|
|
||
| registerSW({ immediate: true }) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another bold move because the flag is missleading and has nothing to do with the automatic reload itself but is only used in a very rare case.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question is, should we mention that flag anywhere? |
||
| registerSW() | ||
| ``` | ||
|
|
||
| ::: info | ||
| In order to reload the client's tab/window, you will need to import the virtual module provided by this plugin. | ||
| If you're not using any virtual modules, there is no way to interact with the application ui, and so, any client tab/window will not be reloaded. | ||
| The old service worker will be still controlling the application up until the next time the PWA has been reopened in the client. | ||
| ::: | ||
|
|
||
| The disadvantage of using this behavior is that the user can lose data in any browser windows/tabs in which the application is open and is filling in a form. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still do not understand this sentence, I admit. I aggressively dropped this sentence.
Without registering the SW in the application nothing is happening here. That the SW installs any new application caches as soon it is triggered to do so happens independently of the
registerType.