Delay

See also

  • Official ReactiveX documentation: Delay
Observable.delay(duetime, scheduler=None)

Time shifts the observable sequence by duetime. The relative time intervals between the values are preserved.

1 - res = rx.Observable.delay(datetime()) 2 - res = rx.Observable.delay(datetime(), Scheduler.timeout)

3 - res = rx.Observable.delay(5000) 4 - res = rx.Observable.delay(5000, Scheduler.timeout)

Keyword arguments: :param datetime|int duetime: Absolute (specified as a datetime object) or

relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.
Parameters:scheduler (Scheduler) – [Optional] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.
Returns:Time-shifted sequence.
Return type:Observable
../../_images/delay.png
Observable.delay_subscription(duetime, scheduler=None)

Time shifts the observable sequence by delaying the subscription.

1 - res = source.delay_subscription(5000) # 5s 2 - res = source.delay_subscription(5000, Scheduler.timeout) # 5 seconds

duetime – Absolute or relative time to perform the subscription at. scheduler [Optional] Scheduler to run the subscription delay timer on.

If not specified, the timeout scheduler is used.

Returns time-shifted sequence.

../../_images/delaySubscription.png
Observable.delay_with_selector(subscription_delay=None, delay_duration_selector=None)

Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.

# with selector only 1 - res = source.delay_with_selector(lambda x: Scheduler.timer(5000)) # with delay and selector 2 - res = source.delay_with_selector(Observable.timer(2000),

lambda x: Observable.timer(x))
subscription_delay – [Optional] Sequence indicating the delay for the
subscription to the source.
delay_duration_selector [Optional] Selector function to retrieve a
sequence indicating the delay for each given element.

Returns time-shifted sequence.

../../_images/delayWithSelector.png