Take¶
See also
- Official ReactiveX documentation: Take
-
Observable.
take
(count, scheduler=None)¶ Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).
1 - source.take(5) 2 - source.take(0, rx.Scheduler.timeout)
Keyword arguments: count – The number of elements to return. scheduler – [Optional] Scheduler used to produce an OnCompleted
message in case count is set to 0.Returns an observable sequence that contains the specified number of elements from the start of the input sequence.
-
Observable.
take_with_time
(duration, scheduler=None)¶ Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
Example: res = source.take_with_time(5000, [optional scheduler])
Description: This operator accumulates a queue with a length enough to store elements received during the initial duration window. As more elements are received, elements older than the specified duration are taken from the queue and produced on the result sequence. This causes elements to be delayed with duration.
Keyword arguments: duration – {Number} Duration for taking elements from the start of the
sequence.- scheduler – {Scheduler} Scheduler to run the timer on. If not
- specified, defaults to rx.Scheduler.timeout.
Returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.