Events
Register a callback for studio events such as settings updates, key presses, comments, participants and fast action buttons.
Both components, the widget and the settings page, can register for events and respond to them.
Register for an event
Call registerEvent with the event name and a callback. The callback receives the event name and the event data:
import EvmuxAppsApi, { availableEvents } from 'evmux-app-framework/src/EvmuxAppsApi/EvmuxAppsApi'
const evmuxApi = new EvmuxAppsApi()
evmuxApi.registerEvent(availableEvents.settingsUpdated, (eventName, eventData) => {
console.log('this is printed on each settings update')
// eventData contains the updated settings object
})
evmuxApi.registerEvent(availableEvents.fastActionButton, (eventName, eventData) => {
console.log('this is printed on a fast action button click')
// eventData.fastAccessButton contains data about the button that was clicked
})
Use the names in availableEvents instead of typing the strings yourself.
To stop listening, call unregisterEvent with the same event name and callback:
evmuxApi.unregisterEvent(availableEvents.settingsUpdated, onSettingsUpdated)
Settings and messaging
| Event | Description |
|---|---|
settingsUpdated |
Called once the app settings changed. The event data is the updated settings object. The component that made the change is not called. |
appMessaging |
In-app messaging between the components of your app. Use it to send messages between your components, or to broadcast a message to all listeners on all endpoints. The event data is the object that was sent. |
externalAppMessaging |
App-to-app messaging. The event data is the object the other app sent. |
fastActionButton |
Called when the user clicks a fast action button that your app registered. |
The data of a fastActionButton event:
{
"fastAccessButton": { "buttonId": "spin", "buttonText": "Spin The Wheel!", "params": {} },
"userAppInstanceId": "4d532c22-363e-4028-824d-7b029f100916",
"componentId": "e9fe6623-4332-447c-bb1a-ccfe9f794bb3"
}
The widget and the user
| Event | Description |
|---|---|
keystroke |
Called on a user keyboard key-down. |
doubleClickOnWidget |
Called when the user double-clicks the widget. |
widgetOnFocus |
Called when the widget gets the focus. |
widgetOnBlur |
Called when the widget loses the focus. |
The show
| Event | Description |
|---|---|
comments |
Called when comments arrive. The event data is a list of comments, in the same shape social.getComments returns. |
viewerCountChanged |
Called when the number of viewers changes. |
participantJoined |
Called when a participant joins the studio. |
participantLeft |
Called when a participant leaves the studio. |
studioParamsUpdated |
Called when the studio parameters change. The event data is the new parameters, as in studio.getStudioParams. |
Sound
| Event | Description |
|---|---|
volumeMultiplier |
Called when the volume multiplier of the component changes. See getVolumeMultiplier. |
signalingEvent |
Called with a WebRTC signaling message for your app. See studio.signal. |
Send a message to your own components
Raise an appMessaging event from any component. The other components of your app that registered for it receive the data:
// in the settings page
evmuxApi.raiseAppMessagingEvent({ action: 'spin' })
// in the widget
evmuxApi.registerEvent(availableEvents.appMessaging, (eventName, eventData) => {
// eventData is the object that was sent
})
To send a message to another app, see sendMessageToApp. To add fast action buttons, see setFastActionButtons.
Stuck, or found a mistake in these docs? Tell us.