Processing Events in the JS SDK

Our SDK relays the following events to the client when the Platform is doing work in the background that may soon cause major changes to the UI.

processing:start

When the server sends the “processing:start” SSE event, it will indicate: “the server is processing (but not sending out messages for) the results of opting into a role or entering a group with replay_history on, among other possible cases”.

processing:stop

When the server sends the “processing:stop” event, it will indicate: “the server is done with processing and now has accurate roster and message content available”.

Examples

Here are some examples of listening to these events:

client.on('processing:start', event => {
console.log('Received processing:start event')
})
client.on('processing:stop', event => {
console.log('Received processing:start event')
})

Reacting to These Events

Our SDK takes care of handling the model changes that occur as a result of these events. Therefore, instead of handling the processing events directly, you will usually only need to listen to the model lifecycle events and react accordingly.

One important note is that we emit a conversation:clearTimeline event to the client whenever a processing:stop event comes in for a group replay or role opt-in/opt-out. You will want to subscribe to that event and refetch the corresponding conversation, if it is visible, to have a list of updated messages.

client.on('conversation:clearTimeline', conversationId => {
if (conversationId === currentConversation.id) {
await client.conversations.selectConversation(currentConversation.id)
}
})