I am developing in Adnroid RxJava with Room.
I use retrofit to call API and update the value in database like the following code:
override fun certifyMail(userInfo: Userinfo): Observable<Int> {
return securityApi.certifyUserInfo(userInfo)
.map {
//return Observable<Status> here
when(it.status){
"OK" -> {
it
}
else -> {
throw Exception(it.msg!!)
}
}
}
.flatMap {
userInfoDataSource.updateUserCertifyMailInfo(userInfo.account,1)
//How to convert the return type to Observable<Int> from Int.
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
}
When the response is OK from API, I will update the value in database like the following.
@Query("UPDATE certify_info SET value = :value WHERE account = :account")
fun updateCertifyMailConfirm(account:String,value: Int):Int
But the return type of database is Int.
How to covert it to Observable<Int> ?
Thanks in advance.