Listening for Events

LAST EDIT Jun 02 2021

As soon as you call watch on a Channel or queryChannels you’ll start to listen to these events. You can hook into specific events:

You can also listen to all events at once:

Client Events

Copied!

Not all events are specific to channels. Events such as the user's status has changed, the users' unread count has changed, and other notifications are sent as client events. These events can be listened to through the client directly:

Connection Events

Copied!

The official SDKs make sure that a connection to Stream is kept alive at all times and that chat state is recovered when the user's internet connection comes back online. Your application can subscribe to changes to the connection using client events.

Stop Listening for Events

Copied!

It is a good practice to unregister event handlers once they are not in use anymore. Doing so will save you from performance degradations coming from memory leaks or even from errors and exceptions (i.e. null pointer exceptions)

Get Event History (Android only)

Copied!

It is possible to request all events in order. This can be useful to search for a specific event or to manually get all events that might have been lost during a connection loss. As the Android's low level client is stateless, it may be necessary to use this feature if you're not using the module stream-chat-android-offline to sync all the events correctly.