Reputation: 587
I'm trying to emits objects from list with 1 sec interval.
AppObservable.bindFragment(this, Observable.from(actionButtonList))
.subscribeOn(Schedulers.newThread())
.flatMap(ab -> Observable.defer(() -> Observable.just(ab).delay(1000, TimeUnit.MILLISECONDS)))
.observeOn(AndroidSchedulers.mainThread())
.doOnEach(notification -> ObjectAnimator.ofFloat(notification.getValue(), "alpha", 1, 0).setDuration(500).start())
.subscribe(ab -> Log.d(TAG, ab.toString()));
With this approach doOnEach is executed at the same time. What am I doing wrong?
Upvotes: 1
Views: 508
Reputation: 69997
You can zip a timer with your list:
Observable
.timer(1, 1, TimeUnit.SECONDS).onBackpressureDrop()
.zipWith(actionButtonList, (t, b) -> b)
.subscribeOn(...)
.observeOn(...)
.doOnNext(...)
.subscribe(...)
Upvotes: 2