Книга: Learning Concurrency in Python
Назад: Transforming observables
Дальше: Error-handling observables

Filtering observables

RxPY provides quite a deep API for filtering observables as well. We've already used the de facto Filter operator in one of our previous examples, but there are others such as Distinct, ElementAt, Sample, and Take, which I recommend you get familiar with.

Again, the following list contains only a subset of the available operators when it comes to filtering:

  • Distinct: This stops an Observable from emitting duplicate items. This is the very operator that takes care of the complexities for filtering lists of duplicates for you.

  • Take: This takes a subset of the first n items emitted by an Observable.

  • ElementAt: This returns the element at position n emitted by an Observable.

Назад: Transforming observables
Дальше: Error-handling observables