Skip to content

Conversation

@rool78
Copy link
Contributor

@rool78 rool78 commented Apr 8, 2023

🎯 Goal

As specified in stream-chat-android documentation, await function is safe to be called from the main thread.

Awaits the result of this [Call] in a suspending way, asynchronously.
Safe to call from any CoroutineContext.

I think this could avoid confusion when trying to learn how to use stream-chat.

🛠 Implementation details

Removed ioDispatcher from WhatsAppMessagesViewModel when fetching channel.

✍️ Explain examples

  private fun fetchChannel(channelId: String) {
    viewModelScope.launch {
      val result = chatClient.channel(channelId).watch().await()
      result.onSuccess {
        messageMutableUiState.value = WhatsAppMessageUiState.Success(result.data())
      }.onError {
        messageMutableUiState.value = WhatsAppMessageUiState.Error
      }
    }
  }

@rool78 rool78 requested a review from skydoves as a code owner April 8, 2023 10:01
Copy link
Contributor

@skydoves skydoves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@skydoves skydoves merged commit b7187b6 into GetStream:main Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants