onEvent
Event publishing handler
This example demonstrates how the onEvent callback
publishes a widget-generated event to a backend synchronization service using the Fetch API. The event is serialized and sent to the
/events
endpoint,
where it can be distributed to other connected clients.
The host application does not need to interpret or modify the event contents and simply forwards the event contents and the event for processing by the synchronization infrastructure.
Event publishing handler
const onEvent = async function(event: DIQ_Event) => {
fetch(`${apiBaseUrl}/events`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(event)
});
};