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
'안드로이드' 카테고리의 다른 글
안드로이드 4+버전에서 애드몹이 안보이는 현상 (2) | 2016.07.05 |
---|---|
No acceptable module found. Local version is 0 and remote version is 0. (2) | 2016.07.05 |
facebook audience-network (329) | 2016.06.18 |
Firebase Auth 와 Realtime Database (6) | 2016.06.12 |
모바일 통계 분석 툴 google Analytics에서 Firebase Analytics로.... (10) | 2016.06.06 |
댓글