I make a request

@SuppressLint("CheckResult") private Observable<Exchange> kursRequest(){ String base = exchange.getBase(); String symbols=symbolsWaluta; return request(base,symbols); } private Observable<Exchange> request(String nameWaluta, String nameWaluta2){ return Network.getService().getDara(nameWaluta,nameWaluta2) .subscribeOn(Schedulers.single()) .observeOn(AndroidSchedulers.mainThread()); } 

Subscribe

 @SuppressLint("CheckResult") public String getKurs() { kursRequest() .subscribe (s->kurs=s.getRates().get(symbolsWaluta).toString()) ; return kurs; } 

I get the result-

kurs

BUT I receive old, that is it is updated, then when I do a repeated request. That is, if kurs==0 , then with 1 request it will remain kurs==0 , it will be updated only with 2 requests. How to fix to get the result right away?

  • interesting question - Martinez Toni
  • Do you mean that you expect the release of a new value as soon as the price changes on the server? If yes, then it must be done quite differently - it connects to the north via sockets (the server should provide such an opportunity). Well, or manually constantly restart the request. - Yuriy SPb

0