Broadcasts an event to other Site components of a multicomponent app. If the app’s Site components span multiple pages, they will be notified when they are rendered.
SDK Version: SDK 1.25.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page, Modal, Popup
Note:
For the Worker component, use the Worker.PubSub.publish method instead.
Syntax:
Parameters:
| Name | Type | Description |
|---|---|---|
| eventName (required) | String | The name of the event to publish |
| data (required) | Object | The object to send to subscribers for this event type |
| isPersistent (required) | Boolean | Indicates whether this event is persisted for event subscribers who have not yet subscribed |
Example:
Subscribes to events from other site components of a multicomponent app. If the components span multiple pages, they will be notified once they are rendered. It is also possible to receive all notifications prior to rendering by specifying a flag when subscribing to events. If the flag is set, the component will be notified immediately of any prior events of the type it is registered to receive.
SDK Version: SDK 1.25.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page, Modal, Popup
Note:
For the Worker component, use the Worker.PubSub.subscribe method instead.
Syntax:
Parameters:
| Name | Type | Description |
|---|---|---|
| eventName (required) | String | The name of the event to subscribe to |
| callBack (required) | Function | Function that will respond to events sent from other components of the broadcasting app. It will be given the event object itself and the source of the event |
| receivePastEvents | Boolean | A flag to indicate that all past instances of the registered event should be sent to registered listener. This will happen immediately upon registration. |
Example:
Unsubscribes from receiving further events. The id from the initial subscribe call is used to unsubscribe from further notifications.
SDK Version: SDK 1.25.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page, Modal, Popup
Syntax:
Parameters:
| Name | Type | Description |
|---|---|---|
| eventName (required) | String | The name of the event to unsubscribe from |
| function (required) | Function | The function that will respond to events sent from other extensions of the broadcasting app. It will be given the event object itself and the source of the event. |
Example: