Skip to content

Commit aeabf27

Browse files
committed
edit
1 parent a2c83f7 commit aeabf27

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

content/en/docs/refguide/mobile/introduction-to-mobile-technologies/service-worker.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ The browser detects this update and initiates a new lifecycle for the updated se
5959

6060
## Detecting and Handling Updates in Your PWA
6161

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.
6463

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:
6665

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:
6967

7068
```javascript
7169
export async function JS_ListenForPWAUpdates() {
@@ -114,8 +112,7 @@ export async function JS_ListenForPWAUpdates() {
114112
}
115113
```
116114

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:
119116

120117
```javascript
121118
import { skipWaiting } from "mx-api/pwa";
@@ -137,9 +134,5 @@ export async function JS_ActivatePWAUpdate() {
137134
}
138135
```
139136

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

Comments
 (0)