watchChannelAsState

fun ChatClient.watchChannelAsState(cid: String, messageLimit: Int, coroutineScope: CoroutineScope = CoroutineScope(DispatcherProvider.IO)): StateFlow<ChannelState?>

Performs ChatClient.queryChannel with watch = true under the hood and returns ChannelState associated with the query. The ChannelState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.

Return

A StateFlow object that emits a null when the user has not been connected yet and the new ChannelState when the user changes.

Parameters

cid

The full channel id, i.e. "messaging:123"

messageLimit

The number of messages that will be initially loaded.

coroutineScope

The CoroutineScope used for executing the request.