android - Timeout without ending stream -


i'm using android-reactivelocation library. display warning message when last x minutes didn't new location updates. new locations should reset timeout.

how can implement kind of timeout without ending stream using rxjava?

you publish source , use timeout retry keep listening source:

observable<long> source =     observable.just(100l, 200l, 500l, 1000l, 5000l, 5500l, 6000l)     .flatmap(v -> observable.timer(v, timeunit.milliseconds).map(a -> v));  source.publish(co -> co.timeout(750, timeunit.milliseconds)         .doonerror(system.out::println)         .retry() ).toblocking().foreach(system.out::println); 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -