android - Why does interval operator in RxJava change the results from flatMap -


i running code:

private void concatenatedsets() {     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))             .interval(200, timeunit.milliseconds)             .subscribeon(schedulers.computation())             .observeon(androidschedulers.mainthread())             .subscribe(new subscriber<long>() {                 @override                 public void oncompleted() {                  }                  @override                 public void onerror(throwable e) {                  }                  @override                 public void onnext(long along) {                     tvcounter.settext(string.valueof(along));                 }             }); } 

the expected output be

1 5 8 1 9 11 58 16 9 15 56 49 21 

however, endless session of counting 1 infinity in 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12...

i think problem came after added

.interval(200, timeunit.milliseconds) 

but don't know why.

interval() factory method on observable gives sequence of values, starting 0, periodically. source operator should statically called observable.interval() called on instance. ides should warn invoking static method on instance because different happen expect.

i suspect want span out values separated 200 ms; there no standard operator in rxjava common question here on (and should have answer already).


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -