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

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!
主站蜘蛛池模板: 大英县| 都兰县| 育儿| 扶绥县| 武邑县| 乐亭县| 容城县| 依兰县| 齐齐哈尔市| 安岳县| 县级市| 西乌| 吉林市| 克东县| 巴林左旗| 富锦市| 浦东新区| 永年县| 黔西| 鹿泉市| 加查县| 思南县| 治县。| 亳州市| 花莲市| 海口市| 门源| 夏邑县| 无锡市| 佛坪县| 灵宝市| 鸡东县| 阜城县| 广丰县| 阳信县| 怀安县| 临桂县| 阿瓦提县| 许昌县| 礼泉县| 阿鲁科尔沁旗|