RxJava delay for each item of list emitted

后端 未结 15 1807
感情败类
感情败类 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:55

    I think it's exactly what you need. Take look:

    long startTime = System.currentTimeMillis();
    Observable.intervalRange(1, 5, 0, 50, TimeUnit.MILLISECONDS)
                    .timestamp(TimeUnit.MILLISECONDS)
                    .subscribe(emitTime -> {
                        System.out.println(emitTime.time() - startTime);
                    });
    

提交回复
热议问题