RxJava delay for each item of list emitted

后端 未结 15 1824
感情败类
感情败类 2020-11-29 00:14

I\'m struggling to implement something I assumed would be fairly simple in Rx.

I have a list of items, and I want to have each item emitted with a delay.

It

15条回答
  •  误落风尘
    2020-11-29 00:46

    There is other way to do it using concatMap as concatMap returns observable of source items. so we can add delay on that observable.

    here what i have tried.

    Observable.range(1, 5)
              .groupBy(n -> n % 5)
              .concatMap(integerIntegerGroupedObservable ->
              integerIntegerGroupedObservable.delay(2000, TimeUnit.MILLISECONDS))
              .doOnNext(item -> {
                        System.out.println(System.currentTimeMillis() - timeNow);
                        System.out.println(item);
                        System.out.println(" ");
                    }).toList().toBlocking().first(); 
    

提交回复
热议问题