I want to get a list of artists from audio recordings VC. instead of responsa silence, "INONCOMPLETE" is not displayed. Moreover, if instead of toBlocking I use onSubscribe, or I throw Observable without Blocking in zip, everything works

bands = Observable.create(new Observable.OnSubscribe<VKResponse>() { @Override public void call(final Subscriber<? super VKResponse> subscriber) { VKApi.audio().get().executeWithListener(new VKRequest.VKRequestListener() { @Override public void onComplete(VKResponse response) { super.onComplete(response); System.out.println("INONCOMPLETE "); subscriber.onNext(response); subscriber.onCompleted(); } @Override public void attemptFailed(VKRequest request, int attemptNumber, int totalAttempts) { super.attemptFailed(request, attemptNumber, totalAttempts); System.out.println("attemptFailed"); subscriber.onError(new Exception("attemptFailed")); } @Override public void onError(VKError error) { super.onError(error); System.out.println(error.toString()); subscriber.onError(new Exception(error.toString())); } @Override public void onProgress(VKRequest.VKProgressType progressType, long bytesLoaded, long bytesTotal) { super.onProgress(progressType, bytesLoaded, bytesTotal); } }); } }) .flatMap(vkResponse -> Observable.from((VKList<VKApiAudio>) vkResponse.parsedModel)) .flatMap(vkApiAudio -> Observable.just(vkApiAudio.artist)) .distinct() .toList() .toBlocking() .single(); 
  • toBlocking() block the stream. Are you sure that this is what you need? - temq
  • that's exactly what i need. block the flow until the result is obtained - Nikolai Konorev
  • Then what's the point in rx if you block the stream? Also, if you block the UI stream, this is an error. Perhaps this is why you have an error, because An exception is thrown due to interaction with the network in the UI stream. - temq
  • one
    and you in ui-flow cause this code? Then it will not take off, because vk-api calls are called in the ui-stream, and it is blocked from you. - zRrr
  • one
    VKApi.audio (). Get (). ExecuteSyncWithListener - what helped - Nikolai Konorev

0