RxJava 1.x Skip first item if it satisfies a condition

Created on 1 Jun 2017  路  2Comments  路  Source: ReactiveX/RxJava

I'm looking for an operator that is like skip(int) but also has a condition and only skips the first item if if satisfies a condition (empty list in my case). If the item is not empty, continue normally, don't try to skip any more items.

Is there a way to do this with current operators?

Most helpful comment

upstream.publish(u -> merge(u.take(1).filter(i -> YOUR_CONDITION_HERE), u.skip(1)))

All 2 comments

upstream.publish(u -> merge(u.take(1).filter(i -> YOUR_CONDITION_HERE), u.skip(1)))

Works great! Thanks!

Was this page helpful?
0 / 5 - 0 ratings