Skip to content

Instantly share code, notes, and snippets.

@msdx msdx/CountDown.java
Created Oct 26, 2017

Embed
What would you like to do?
rxjava countdown
Subscription subscription = Observable.interval(0, 1, TimeUnit.SECONDS)
.take(seconds + 1)
.map(new Func1<Long, Long>() {
@Override
public Long call(Long past) {
return seconds - past - 1;
}
})
.filter(new Func1<Long, Boolean>() {
@Override
public Boolean call(Long aLong) {
return aLong >= 0;
}
})
.subscribe(new RxAction<Long>() {
@Override
public void onNext(Long time) {
Log.e("xxxxxx", "onNext" + time);
}
@Override
public void onStart() {
Log.e("xxxxxx", "onStart");
}
@Override
public void onCompleted() {
Log.e("xxxxxx", "onCompleted");
}
});
@msdx

This comment has been minimized.

Copy link
Owner Author

msdx commented Oct 26, 2017

9.8.7.6.5.4.3.2.1.0.complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.