android - How do I convert this RxJava observable to emit results every 200 ms? -
i have observable:
observable<string> concatenatedsets = observable.just("1/5/8", "1/9/11/58/16/", "9/15/56/49/21"); concatenatedsets.flatmap(s -> observable.from(s.split("/"))) .map(s -> integer.valueof(s)) .subscribeon(schedulers.computation()) .observeon(androidschedulers.mainthread()) .subscribe(i -> tvcounter.settext(string.valueof(i)));
how convert or operator chain onnext
called 200 ms in between calls?
i looking @ question: pause between call onnext in rxjava
but answers there start creating pause using interval
so
observable.interval(100, timeunit.milliseconds)
however, creating observable in way (using just
), how mix both functionalities (just
, interval
) or do achieve pause of 200 ms between emissions?
ps: tried delay
- postponed overall execution once time provided. zip
might answer confusing, how zip observable , interval one?
observable<integer> observable = observable.just("1/5/8", "1/9/11/58/16/", "9/15/56/49/21") .flatmap(s -> observable.from(s.split("/"))) .map(s -> integer.valueof(s)); observable<integer> zippedobservable = observable.zip( observable, observable.interval(100, timeunit.milliseconds), (number, interval) -> number); zippedobservable .subscribeon(schedulers.computation()) .observeon(androidschedulers.mainthread()) .subscribe(i -> tvcounter.settext(string.valueof(i)));
Comments
Post a Comment