本文整理了Java中rx.Observable.finallyDo()
方法的一些代码示例,展示了Observable.finallyDo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.finallyDo()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:finallyDo
[英]Registers an Action0 to be called when this Observable invokes either Observer#onCompleted or Observer#onError.
Scheduler: finallyDo does not operate by default on a particular Scheduler.
[中]当此Observable调用Observator#onCompleted或Observator#onError时,注册要调用的Action0。
调度程序:默认情况下,finallyDo不会在特定的调度程序上运行。
代码示例来源:origin: leeowenowen/rxjava-examples
@Override
public void run() {
Observable.just(1, 2).finallyDo(new Action0() {
@Override
public void call() {
log("finallyDo");
}
}).subscribe(new Action1<Integer>() {
@Override
public void call(Integer integer) {
log(integer);
}
});
}
});
代码示例来源:origin: Q42/RxPromise
/**
* Add a callback for when the promise is either fulfilled or rejected. This callback cannot be unsubscribed.
*/
public Promise<T> onFinally(Action0 finallyDo) {
return new Promise<T>(this.observable.finallyDo(finallyDo));
}
代码示例来源:origin: com.netflix.zuul/zuul-netty
.finallyDo(() -> {
timing.end();
if (stats != null)
代码示例来源:origin: com.netflix.zuul/zuul-servletapi
requestBuiltObs.finallyDo(() -> readTiming.end() );
代码示例来源:origin: io.reactivex/rxnetty
protected Observable<HttpClientResponse<O>> submit(final HttpClientRequest<I> request,
final Observable<ObservableConnection<HttpClientResponse<O>, HttpClientRequest<I>>> connectionObservable,
final ClientConfig config) {
final long startTimeMillis = Clock.newStartTimeMillis();
HttpClientConfig httpClientConfig;
if (config instanceof HttpClientConfig) {
httpClientConfig = (HttpClientConfig) config;
} else {
httpClientConfig = new HttpClientConfig(config);
}
boolean followRedirect = shouldFollowRedirectForRequest(httpClientConfig, request);
enrichRequest(request, httpClientConfig);
Observable<HttpClientResponse<O>> toReturn =
connectionObservable.lift(new RequestProcessingOperator<I, O>(request, eventsSubject,
httpClientConfig.getResponseSubscriptionTimeoutMs()));
if (followRedirect) {
toReturn = toReturn.lift(new RedirectOperator<I, O>(request, this, httpClientConfig));
}
return toReturn.take(1).finallyDo(new Action0() {
@Override
public void call() {
eventsSubject.onEvent(HttpClientMetricsEvent.REQUEST_PROCESSING_COMPLETE,
Clock.onEndMillis(startTimeMillis));
}
});
}
代码示例来源:origin: com.netflix.rxnetty/rx-netty
protected Observable<HttpClientResponse<O>> submit(final HttpClientRequest<I> request,
final Observable<ObservableConnection<HttpClientResponse<O>, HttpClientRequest<I>>> connectionObservable,
final ClientConfig config) {
final long startTimeMillis = Clock.newStartTimeMillis();
HttpClientConfig httpClientConfig;
if (config instanceof HttpClientConfig) {
httpClientConfig = (HttpClientConfig) config;
} else {
httpClientConfig = new HttpClientConfig(config);
}
boolean followRedirect = shouldFollowRedirectForRequest(httpClientConfig, request);
enrichRequest(request, httpClientConfig);
Observable<HttpClientResponse<O>> toReturn =
connectionObservable.lift(new RequestProcessingOperator<I, O>(request, eventsSubject,
httpClientConfig.getResponseSubscriptionTimeoutMs()));
if (followRedirect) {
toReturn = toReturn.lift(new RedirectOperator<I, O>(request, this, httpClientConfig));
}
return toReturn.take(1).finallyDo(new Action0() {
@Override
public void call() {
eventsSubject.onEvent(HttpClientMetricsEvent.REQUEST_PROCESSING_COMPLETE,
Clock.onEndMillis(startTimeMillis));
}
});
}
内容来源于网络,如有侵权,请联系作者删除!