ursus
06/21/2019, 3:26 PMkioba
06/21/2019, 3:36 PMmessageRepository
.insertSendingTextMessage(...)
.flatMap { messageId ->
apiClient.postMessage(...)
.flatMap{ apiMessage -> messageRepository.updateSentMessageAndParents(apiMessage) }
.onErrorResumeNext { error ->
messageRepository.updateMessageState(messageId, MessageState.ERROR) }
.flatMap{ Observable.error(error) }
}// ONLY if you want to trigger the error but My suggestion would be to return a Succes() / Error() sealed class.
}
kioba
06/21/2019, 3:42 PM.flatMap{ Observable.error(error) }
at the end is there only because when you catch an exception you also throw it again. but it is up to you if you want to keep it or not 🙂ursus
06/21/2019, 3:55 PMif (messageId != null) messageRepository.updateMessageState(messageId, MessageState.ERROR)
catch?ursus
06/21/2019, 3:56 PMinsertSendingTextMessage
, right?kioba
06/21/2019, 3:58 PMinsertSendingTextMessage
fails, it never executes the inner part so the onErrorResumeNext { updateMessageState() }
never gets called.ursus
06/21/2019, 3:58 PMkioba
06/21/2019, 3:59 PM