All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cmonbaby.http.rxjava.CallExecuteOnSubscribe Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.cmonbaby.http.rxjava;

import retrofit2.Call;
import retrofit2.Response;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.exceptions.Exceptions;

/**
 * 

Author: Simon *

QO: 8950764 *

Email: [email protected] *

WebSize: https://www.cmonbaby.com *

Version: 1.0.0 *

Date: 2020/12/28 *

Description: */ final class CallExecuteOnSubscribe implements OnSubscribe> { private final Call originalCall; CallExecuteOnSubscribe(Call originalCall) { this.originalCall = originalCall; } @Override public void call(Subscriber> subscriber) { // Since Call is a one-shot type, clone it for each new subscriber. Call call = originalCall.clone(); CallArbiter arbiter = new CallArbiter<>(call, subscriber); subscriber.add(arbiter); subscriber.setProducer(arbiter); Response response; try { response = call.execute(); } catch (Throwable t) { Exceptions.throwIfFatal(t); arbiter.emitError(t); return; } arbiter.emitResponse(response); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy