This is the code example (written on Kotlin). I'm trying to fetch jwt token from the server on "get_jwt" button click. On "remove_jwt" I'm deleting all Jwt objects.
The problem is that jwtList result is empty on the first click. Then I clicked twice - the data is loaded as need.
val client = TravelerClient.getInstance<TravelerClient>()
if (view.id == R.id.get_jwt) {
client.getJwt("some_access_token").subscribe { jwtList -> if (jwtList.size > 0) input.text = jwtList.first().token }
} else if (view.id == R.id.remove_jwt) {
client.storage.executeTransaction { realm -> realm.delete(Jwt::class.java) }
input.text = ""
}
it seems you're retrieving data from realm db (which is empty on the first call), after that making a request to a server and finally updating realm (ApiObserver.java), so subscriber don't getting the actual result.
This is the code example (written on Kotlin). I'm trying to fetch jwt token from the server on "get_jwt" button click. On "remove_jwt" I'm deleting all Jwt objects. The problem is that jwtList result is empty on the first click. Then I clicked twice - the data is loaded as need.