Zip

See also

  • Official ReactiveX documentation: Zip
classmethod Observable.zip(*args)

Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.

The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the sources.

Parameters:args (List[Observable]) – Observable sources.
Returns:an observable sequence containing the result of combining elements of the sources using the specified result selector function.
Return type:Observable
../../_images/zip.png
>>> from rx.testing import marbles
>>> xs = rx.Observable.from_marbles('--1-2-3-|')
>>> ys = rx.Observable.from_marbles('-a-b-c-d-e|')
>>> source = xs.zip(ys, lambda x, y: x+y)
>>> subscription = source.subscribe(
...     lambda value: print("Next:", value),
...     lambda error: print("Error:", error),
...     lambda: print("Complete!"))
Next: 1a
Next: 2b
Next: 3c
Complete!
classmethod Observable.zip_array(*args)

Merge the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.

Parameters:args (Tuple) – Observable sources.
Returns:Returns an observable sequence containing lists of elements at corresponding indexes.
Return type:Observable
../../_images/zipArray.png
classmethod Observable.zip_list(*args)

Merge the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.

Parameters:args (Tuple) – Observable sources.
Returns:Returns an observable sequence containing lists of elements at corresponding indexes.
Return type:Observable