RxJava2操作符之“Delay”

作用

顾名思义,delay操作符的作用就是延时发射Observable里面的事件

Observable.just("Amit")
                //延时两秒,第一个参数是数值,第二个参数是事件单位
                .delay(2, TimeUnit.SECONDS)
                // Run on a background thread
                .subscribeOn(Schedulers.io())
                // Be notified on the main thread
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(getObserver());//这里的观察者依然不重要

两秒钟之后,观察者收到事件 -> “Amit”