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

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!
主站蜘蛛池模板: 乐安县| 兴城市| 桂林市| 东安县| 定边县| 丰原市| 黄陵县| 宁乡县| 南阳市| 广饶县| 青阳县| 靖西县| 汶上县| 东明县| 维西| 积石山| 布尔津县| 文化| 乐都县| 汉沽区| 都昌县| 城固县| 响水县| 新巴尔虎右旗| 阿瓦提县| 乐陵市| 北宁市| 乌审旗| 曲松县| 浏阳市| 古浪县| 嘉禾县| 张北县| 嘉兴市| 琼海市| 陆川县| 南溪县| 九寨沟县| 青阳县| 洛阳市| 吉首市|