radixdlt/radixdlt-java

RadixWallet#getXRDSubUnitBalance Observable does not receive onComplete

Closed this issue · 1 comments

I'm checking my balance using:

import io.reactivex.Observable
import io.reactivex.Observer

// ...

Observer<Long> observer = // ...
Observable<Long> balance = RadixWallet.getInstance().getXRDSubUnitBalance(myAddress);

Now initially I just got the balance by using the first result to onNext on that Observer.
However, it happens occasionally that the first result is a 0 and then a second one comes in with the actual balance.

It's confusing that there would be a 0 first. But ok, in that case, I thought, I could just use the last result before onComplete gets called. But it never is called. Shouldn't there be a call to onComplete, though?

getXRDSubUnitBalance never completes because it is a stream of the balance as it updates over time. This is currently implemented via a debounce which is why the first result is 0 sometimes. It's clear though that there needs to be a method call which only returns a single balance and completes.