As title says, I want to download file using RxJava2 and okhttp. And also process is needed.
In my opinion, the data flow is String url
-> Response
-> multiply Float process
.
So first I need a Single
which emits Response
.
Single.create((SingleOnSubscribe<Response>) emitter -> {
emitter.onSuccess(xx);// or throw error
});
Next I need Flowable
right? Because I want to emit multiply process info to Observer.
So here how can I do ? Thanks in advance.
EDIT
I tried to convert Single
to Flowable
.
Single.create((SingleOnSubscribe<Response>) emitter -> {
emitter.onSuccess(xxx);// or throw error
}).toFlowable()
.flatMap((Function<Response, Publisher<Float>>) response -> Flowable.create(xxx))
.subscribe(process -> {});
}
But I do not know whether it's suitable to do like this.
EDIT
I do not care about the okhttp details and I only care about something relevant to RxJava
such as Single
and Flowable
.