RxJava - delay
RxJava Delay
Observable<String> myObservable = Observable.create(
new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
subscriber.onNext("text1");
subscriber.onNext("text2");
subscriber.onCompleted();
}
}
).delay(2, TimeUnit.SECONDS, Schedulers.trampoline());
myObservable.subscribe(subScriber);
private Subscriber<String> subScriber = new Subscriber<String>() {
@Override
public void onCompleted() {
Log.e("complete", "complete");}
@Override
public void onError(Throwable e) {
Log.e("err", e.getMessage());
}
@Override
public void onNext(String s) {
Log.e("res", s);
}
};
result
06-25 02:40:43.655 12316-12316/com.akaisun.school E/time: 02:43
06-25 02:40:43.655 12316-12316/com.akaisun.school E/s: text1
06-25 02:40:45.655 12316-12316/com.akaisun.school E/time: 02:45
06-25 02:40:45.655 12316-12316/com.akaisun.school E/s: text2
06-25 02:40:47.655 12316-12316/com.akaisun.school E/complete: complete
출처: https://akaisun.tistory.com/28?category=622886 [아카이의 개발창고]
'안드로이드 > 개발 TIP' 카테고리의 다른 글
library version check (0) | 2020.12.09 |
---|---|
log 관리하기 (0) | 2020.12.09 |
안드로이드 4+버전에서 애드몹이 안보이는 현상 (0) | 2020.12.09 |
No acceptable module found. Local version is 0 and remote version is 0. (0) | 2020.12.09 |
facebook audience-network (0) | 2020.12.09 |
Firebase Auth 와 Realtime Database (0) | 2020.12.09 |
모바일 통계 분석 툴 google Analytics에서 Firebase Analytics로... (0) | 2020.12.09 |
Android Issue Tracker 디버깅을 쉽게 !! Fabric crashlytics (0) | 2020.12.09 |