简体   繁体   中英

How to assert min. time between observable emits

I have an RxJS observable that emits values after random times between 0 and 1000ms.

How do I assert that there is a gap of at least 200ms between each emit of the observable? No values should be dropped / skipped and values should still be emitted in the order they come in.

you could achieve that by combining your source observable with interval operator, using the zip operator.

zip documentation from rxjs:

Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each of its input Observables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM