Skip to content

Commit 381cbd7

Browse files
committed
chore: refresh documentation to cover new widget shipped with v4
1 parent 002d265 commit 381cbd7

1 file changed

Lines changed: 57 additions & 29 deletions

File tree

  • content/en/docs/marketplace/platform-supported-content/services

content/en/docs/marketplace/platform-supported-content/services/pusher.md

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ aliases:
99

1010
## Introduction
1111

12-
The [Pusher](https://marketplace.mendix.com/link/component/107957/) service allows you to trigger a microflow or nanoflow directly from the server on non-native client apps. This means it is triggered from the other session, without waiting for end-users to interact with the page.
12+
The [Pusher](https://marketplace.mendix.com/link/component/107957/) service lets you trigger a client action from the server in non-native client apps. This means an action can be triggered by another user session without waiting for end-user interaction.
1313

14-
In the standard situation, updates in the client are triggered by a user interaction, by timed actions, or by data-grid refresh time. For information not created by the same user session that needs to be updated immediately in the client app, the Mendix core product does not support a viable option to accomplish this. As an alternative, you need to refresh the page constantly with timers or constant clicking. This is not user-friendly, and it is not preferred when scaling.
14+
In standard scenarios, client updates are triggered by user interaction, timed actions, or data grid refresh intervals. When data is changed outside the current user session and must be updated immediately in the client, the Mendix core product does not provide a direct option. As an alternative, you can refresh the page continuously by using timers or repeated clicks, but this is not user-friendly and does not scale well.
1515

16-
With this service, you can create a notify event on the server that directly causes an action in the client application. The event is based on a persistable object that is available in the server and the client page. From a microflow, the notify action will send a message to every listening widget that is listening to the same object and the action name.
16+
With this service, you can create a notify event on the server that directly triggers a configured client action in the client app. The event is based on a persistable object that is available on the server and on the client page. When the server-side **Notify** action is executed from a microflow, it sends a message to every listening widget that listens to the same object and action name.
1717

1818
{{% alert color="info" %}}
19-
The listening widget can only listen when the page is active, so the widget cannot be used to send a notification when the user has navigated away.
19+
The listening widget only listens while the page is active, so it cannot receive a notification after the user navigates away from the page.
2020
{{% /alert %}}
2121

2222
### Typical Use Cases
2323

2424
* Asynchronous refreshes
2525
* Notifications
26-
* Chat function
26+
* Chat functions
2727

2828
### Dependencies
2929

30-
* External service [Pusher](https://pusher.com/) – the service is built around the Pusher [Channels](https://pusher.com/channels) product; Pusher is a paid service, but there is a generous [free Sandbox plan](https://pusher.com/channels/pricing):
30+
* External service [Pusher](https://pusher.com/). The service is built around Pusher [Channels](https://pusher.com/channels). Pusher is a paid service and also provides a [free Sandbox plan](https://pusher.com/channels/pricing):
3131

3232
| Detail | Sandbox |
3333
| --- | --- |
@@ -38,57 +38,85 @@ The listening widget can only listen when the page is active, so the widget cann
3838
| Support | Limited |
3939
| Protection | SSL |
4040

41+
### React Client Compatibility
42+
43+
Versions earlier than v4 do not support React client apps. Starting with v4, this module includes a new widget that supports React client apps while the legacy widget remains available. Both widgets can be used side by side while migrating to React client. The runtime parts stay the same for both widgets. The new widget is compatible with Mendix 11.11 and later.
44+
4145
## Setting Up the Pusher App
4246

43-
To set up the necessary Pusher app, follow these steps:
47+
To set up the Pusher app, follow these steps:
4448

4549
1. Sign up at [Pusher](https://dashboard.pusher.com/accounts/sign_up).
46-
2. From the dashboard, create an app
47-
3. On the **Channels Apps** page, select the new app. The keys are shown in **App Keys**.
50+
2. In the dashboard, create an app.
51+
3. On the **Channels Apps** page, select the new app. The keys are listed in **App Keys**.
4852
4. Copy the key information into the following **Pusher** service constants:
4953
* `app_id``Pusher_App_ID`
5054
* `key``Pusher_Key`
5155
* `secret``Pusher_Secret`
5256
* `cluster``Pusher_Cluster`
5357

5458
{{% alert color="info" %}}
55-
Make sure you have different apps (keys) created for each app and environment (development, acceptance, and production). When the credentials are shared, messages could go across environments and have unwanted side effects. The configuration can also be set per developer via **App Settings** > **Edit** configuration > [Constants](/refguide/configurations-tab/#constants).
59+
Use different apps (keys) per Mendix app and environment (development, acceptance, and production). If credentials are shared, messages can cross environments and cause unwanted side effects. You can also set the configuration per developer via **App Settings** > **Edit** configuration > [Constants](/refguide/configurations-tab/#constants).
5660
{{% /alert %}}
5761

5862
## Configuration
5963

60-
To use this service after importing it from the Marketplace, follow these steps:
64+
After you import this module from the Marketplace, configure both parts:
65+
66+
* Server-side configuration for sending notify messages.
67+
* Client-side configuration for listening to notify messages and executing client actions.
68+
69+
### Server Side Configuration
70+
71+
Follow these steps to configure the server side:
6172

6273
1. Add the **Pusher User** [module role](/refguide/module-security/#module-role) to the relevant app security [user role](/refguide/security/#user-role).
63-
2. Update the constants in the **Configuration** folder with the keys of the app.
64-
3. Create a microflow to execute the **Notify** action with the following input parameters:
74+
2. Update the **Pusher** service constants in the **Configuration** folder with the app keys.
75+
3. Create a microflow that executes the **Notify** action with these input parameters:
6576
* Key settings
66-
* **Action name** same as configured in the widget
67-
* The context object of the widget
68-
4. Place the widget in a page within a [data view](/refguide/data-view/), where the context should match the parameter object.
69-
5. In the **Action list**, add an action in which the **Action name** matches the action name parameter provided in the **Notify** action.
70-
6. Select a microflow or nanoflow the execute the action.
77+
* **Action name** that matches the action name configured in the widget
78+
* Context object of the widget
79+
80+
### Client Side Configuration
81+
82+
To receive notify messages in the client, place a widget on a page inside a [data view](/refguide/data-view/). The widget listens for notify messages from the server and executes the configured client action when a message is received.
83+
84+
#### React-Compatible Widget
85+
86+
1. Place the new widget on a page within a [data view](/refguide/data-view/) where the context matches the parameter object.
87+
2. Configure **Action list**. For each entry:
88+
* **Action name** matches the notify message name sent from the server.
89+
* **Action** defines the client action to run when the message is received. The new widget can run any configured client action. For example, you can run a microflow to retrieve committed data and refresh the page.
90+
91+
#### Legacy Widget
92+
93+
1. Place the legacy widget on a page within a [data view](/refguide/data-view/) where the context matches the parameter object.
94+
2. Configure **Action list**. For each entry:
95+
* **Action name** matches the notify message name sent from the server.
96+
* Select whether a nanoflow or microflow is executed when the message is received.
97+
98+
### Fetching Updated Data Example
7199

72-
This diagram describes updating an object via the Notify action:
100+
You can use a microflow to retrieve data changed by other users, as long as the data is committed and the transaction is complete.
73101

74-
{{< figure src="/attachments/appstore/platform-supported-content/services/pusher/SequenceDiagramUpdateObject.png" alt="update object via notify listen" class="no-border" >}}
102+
In this example the `$Message` variable contains the object in session state. Use the `[id = $Message]` XPath query to retrieve the object from the database. The change action refreshes the client, which triggers an update on the client page.
75103

76-
### Refresh Microflow
104+
{{< figure src="/attachments/appstore/platform-supported-content/services/pusher/RefreshMicroflowSample.png" alt="Sample refresh microflow that retrieves updated data for the current page" class="no-border" >}}
77105

78-
You can use a microflow to retrieve data that is changed by other users as long is it committed and the transaction has finished.
106+
## Working Flow
79107

80-
The `$Message` variable contains the object in the session state. With the `[id = $Message]` XPath query, the object is retrieved from the database. The changes action only does a refresh in the client, which triggers a refresh update on the client page.
108+
This diagram shows how an object is updated through the **Notify** action:
81109

82-
{{< figure src="/attachments/appstore/platform-supported-content/services/pusher/RefreshMicroflowSample.png" alt="refresh microflow" class="no-border" >}}
110+
{{< figure src="/attachments/appstore/platform-supported-content/services/pusher/SequenceDiagramUpdateObject.png" alt="Sequence diagram for updating an object through notify and listen" class="no-border" >}}
83111

84-
### Security
112+
## Security
85113

86-
The notify messages are sent to anybody who is listening.
114+
Notify messages are sent to any listener.
87115

88-
A message will contain limited data (entity name, ID, changed date, notifier user name). To send a notify message, it is required to have the private key that is stored on the server in the `NotifyListen.secret` constant. This secret should not be shared with anybody. The listening widget will use the public `NotifyListen.key` to receive a signal and perform the action as the logged-in user.
116+
A message contains limited data (entity name, ID, changed date, and notifier username). Sending a notify message requires the private key stored on the server in the `NotifyListen.secret` constant. Do not share this secret. The listening widget uses the public `NotifyListen.key` to receive a signal and perform the action as the logged-in user.
89117

90-
An addition authentication request is made to the Mendix REST server via `<host>/rest/pusher/key` and `<host>/rest/pusher/auth`. Only when successful is the user allowed to access the lists. The service will only allow a logged-in user with the **NotifyListen.User** module role to listen when the user has entity access to the object of the data in which the widget is placed.
118+
An additional authentication request is made to the Mendix REST server through `<host>/rest/pusher/key` and `<host>/rest/pusher/auth`. Only after successful authentication can a user access the lists. The service only allows a logged-in user with the **NotifyListen.User** module role to listen when the user has entity access to the object used by the widget's data context.
91119

92120
## Strict CSP Compatibility
93121

94-
This service requires additional configuration to be compliant with strict content security policy (CSP). The Pusher service makes use of an external service for its functionalities. To make this service work, you need to configure the CSP headers to allow resources from that domain.
122+
This service requires extra configuration to comply with a strict content security policy (CSP). The Pusher service uses an external service for its functionality. To make this service work, configure CSP headers to allow resources from that domain.

0 commit comments

Comments
 (0)