官术网_书友最值得收藏!

Completable

Completable is simply concerned with an action being executed, but it does not receive any emissions. Logically, it does not have  onNext() or onSuccess() to receive emissions, but it does have onError() and onComplete():

    interface CompletableObserver<T> {
void onSubscribe(Disposable d);
void onComplete();
void onError(Throwable error);
}

Completable is something you likely will not use often. You can construct one quickly by calling Completable.complete() or Completable.fromRunnable(). The former will immediately call onComplete() without doing anything, while fromRunnable() will execute the specified action before calling onComplete():

    import io.reactivex.Completable;

public class Launcher {

public static void main(String[] args) {

Completable.fromRunnable(() -> runProcess())
.subscribe(() -> System.out.println("Done!"));

}
public static void runProcess() {
//run process here
}
}

 The output is as follows:

    Done!
主站蜘蛛池模板: 台南县| 安平县| 巩留县| 沈阳市| 南和县| 沾益县| 兴安县| 寿宁县| 长子县| 兰州市| 章丘市| 炉霍县| 定西市| 乐清市| 巍山| 岢岚县| 古蔺县| 永泰县| 印江| 东至县| 雅安市| 合水县| 沧源| 通州区| 永修县| 九龙坡区| 娄烦县| 平远县| 江华| 鸡东县| 远安县| 都江堰市| 红原县| 武隆县| 阳江市| 平潭县| 天镇县| 图木舒克市| 石楼县| 哈密市| 合作市|