copy User Message Flow
fun BaseChannel.copyUserMessageFlow(targetChannel: BaseChannel, userMessage: UserMessage): Flow<MessageResult<UserMessage>>
Copies a user message from this channel to the target channel. ** Sample code **
baseChannel.copyUserMessageFlow(targetChannel, userMessage)
.onEach {
when (it) {
is MessageResult.Pending -> {
// called it when sending message are called
// it contains pendingMessage
}
is MessageResult.Succeed -> {
// called it with result data when all job has been completed
}
is MessageResult.Failure -> {
// deliver exception with failed message when all job has been completed
// it.message : failed message
// it.e : exception
}
}
}.catch {
// error occurred (validation failed)
}.launchIn(viewModelScope)
Content copied to clipboard
Return
The copied user message
Since
4.17.0
Parameters
target Channel
The target channel to copy user message
user Message
The user message to copy