The element_at operator

The element_at operator returns the nth item of the source observable. The following figure shows its marble diagram:

Figure 9.12: The element_at operator

The prototype of this operator is the following:

Observable.element_at(self, index)

Here, index is the index of the item to return, starting from index 0.

Here is an example of the element_at operator:

numbers = Observable.from_([1, 2, 3, 4, 5, 6])
numbers.element_at(3).subscribe(
on_next = lambda i: print("on_next {}".format(i)),
on_error = lambda e: print("on_error: {}".format(e)),
on_completed = lambda: print("on_completed")
)

This gives the following result:

on_next 4
on_completed
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.144.108