You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/refguide/mobile/introduction-to-mobile-technologies/service-worker.md
+6-13Lines changed: 6 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,13 +59,11 @@ The browser detects this update and initiates a new lifecycle for the updated se
59
59
60
60
## Detecting and Handling Updates in Your PWA
61
61
62
-
The [ServiceWorkerRegistration](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration) interface provides properties and methods to monitor its state and detect updates. Starting from Mendix 11.9.0, a client API is available to skip the waiting phase and immediately activate the new service worker version.
63
-
You can implement a custom update mechanism to notify users when a new version is available and allow them to update the application without closing all tabs/windows.
62
+
The [ServiceWorkerRegistration](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration) interface provides properties and methods to monitor its state and detect updates. In Mendix 11.9.0 and above, a Client API ____ is available to skip the waiting phase and immediately activate the new service worker version.
64
63
65
-
Implementation Steps:
64
+
You can implement a custom update mechanism to notify users when a new version is available. This allows them to update the application without closing all tabs or windows:
66
65
67
-
1. Listen for service worker updates
68
-
Create a JavaScript Action to Listen for service worker updates. This action should run when your application starts up, for example, calling the JavaScript action via nanoflow that triggers by [Events](/appstore/widgets/events/) widget
66
+
1.**Listen for service worker updates** — Create a JavaScript Action to listen for service worker updates. This action should run when your application starts up, for example, calling the JavaScript action via nanoflow that triggers by [Events](/appstore/widgets/events/) widget:
69
67
70
68
```javascript
71
69
exportasyncfunctionJS_ListenForPWAUpdates() {
@@ -114,8 +112,7 @@ export async function JS_ListenForPWAUpdates() {
114
112
}
115
113
```
116
114
117
-
2. Create JavaScript Action to activate the new service worker
118
-
When the user confirms the update, use the Client API `skipWaiting()` to activate the new service worker.
115
+
2.**Create a JavaScript Action to activate the new service worker** — When the user confirms the update, use the Client API `skipWaiting()` to activate the new service worker:
119
116
120
117
```javascript
121
118
import { skipWaiting } from"mx-api/pwa";
@@ -137,9 +134,5 @@ export async function JS_ActivatePWAUpdate() {
137
134
}
138
135
```
139
136
140
-
3. Notifying users
141
-
To avoid interrupting users during critical operations, it is recommended to notify them when an update becomes available.
142
-
For example, you can implement a nanoflow that prompts users to confirm the update when a new version is detected. If the user confirms, the nanoflow can call JS_ActivatePWAUpdate to update. This nanoflow can be passed as a parameter to `JS_ListenForPWAUpdates`, which will invoke it when an update is detected.
143
-
144
-
4. Reload the Application
145
-
Trigger a reload, or ask users to reload all open tabs or windows to ensure the application loads with the newly activated service worker.
137
+
3.**Notifying users** — To not interrupt users during critical operations, Mendix recommends notifying them when an update becomes available. For example, you can implement a nanoflow that prompts users to confirm the update when a new version is detected. If the user confirms, the nanoflow can call `JS_ActivatePWAUpdate` to update. This nanoflow can be passed as a parameter to `JS_ListenForPWAUpdates`, which will invoke it when an update is detected.
138
+
4.**Reload the Application** — Trigger a reload, or ask users to reload all open tabs or windows to ensure the application loads with the newly activated service worker.
0 commit comments