What I would like to do is create a function which runs another function every second. The second function returns Observables<A>
and I want the first function to return Observables<A>
as well instead of Observable<Observable<A>>
for example:
private A calcA(){
...
return new A(...)
}
public Observable<A> getAs(){
return Observable.create( subscriber -> {
Bool condition = ...
do {
subscriber.onNext(calcA())
} while (condition)
subscriber.onComplete()
})
}
public Observable<A> pollAs(){
return Observable.create(subscriber -> {
do {
subscriber.onNext(getAs()) // Flatten here I guess
Thread.sleep(1000)
} while(true)
})
So I would like to do something similar (I tried to write this in a Java-ish way, but I will use Kotlin)