RxJava & Kotlin: Conditionally delaying the first item in a stream

Kirill Rakhman
May 25, 2016 · 3 min read

The code

Examples

1464210578099: start
1464210578909: 0
1464210578909: 1
1464210578909: 2
1464210578909: 3
1464210579106: 4
1464210579306: 5
1464210579506: 6
1464210579706: 7
1464210579906: 8
1464210580106: 9

Making the observable reusable

val delayed = Observable.defer { source.delayUntil(3L) }
val delayed = source.delayUntil(3L).cache()

Kirill Rakhman

Written by

Technology lover, Android, Java & Kotlin dev | web: rakhman.info

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade