3 Ocak 2022 Pazartesi

Flux.delaySequence

Giriş
delayElements metodundan farklı. Açıklaması şöyle. Yani initial delay olarak düşünülebilir.
With this operator, a source emitting at 10Hz with a delaySequence Duration of 1s will still emit at 10Hz, with an initial "hiccup" of 1s. On the other hand, delayElements(Duration) would end up emitting at 1Hz.
Örnek
Şöyle yaparız
@GetMapping("/incidenceFlux/{env}/{server}")
public Flux<Incidence> findAllFlux(@PathVariable String env, @PathVariable String server) {
  return Flux.just(new Incidence(...),
     new Incidence(...),
   new Incidence(...)
    )
    .delaySequence(Duration.ofSeconds(3));
}

Hiç yorum yok:

Yorum Gönder