Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rxjs conditional delay

Tags:

rxjs5

I want an observable to be delayed depending on its value. For example:

of(someBool).pipe(delay(1000))

skip delay when someBool is false, but wait a sec when it's true.

like image 358
Hikmat G. Avatar asked May 07 '18 18:05

Hikmat G.


1 Answers

Note: In future versions, empty notifiers will no longer re-emit the source value on the output observable.

someBool$.pipe(
  delayWhen(val => val ? timer(1000) : timer(0))
)
like image 113
am0wa Avatar answered Sep 16 '22 11:09

am0wa