Contains

See also

  • Official ReactiveX documentation: Contains
Observable.contains(value, comparer=None)

Determines whether an observable sequence contains a specified element with an optional equality comparer.

Example 1 - res = source.contains(42) 2 - res = source.contains({ “value”: 42 }, lambda x, y: x[“value”] == y[“value”)

Keyword parameters: value – The value to locate in the source sequence. comparer – {Function} [Optional] An equality comparer to compare elements.

Returns an observable {Observable} sequence containing a single element determining whether the source sequence contains an element that has the specified value.

../../_images/contains.png
Observable.find(predicate)

Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.

Keyword arguments: predicate – {Function} The predicate that defines the conditions of the

element to search for.

Returns an Observable {Observable} sequence with the first element that matches the conditions defined by the specified predicate, if found otherwise, None.

../../_images/find.png
Observable.find_index(predicate)

Searches for an element that matches the conditions defined by the specified predicate, and returns an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.

Keyword Arguments: predicate – {Function} The predicate that defines the conditions of the

element to search for.

Returns an observable {Observable} sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.

../../_images/findIndex.png
Observable.is_empty()

Determines whether an observable sequence is empty.

Returns an observable {Observable} sequence containing a single element determining whether the source sequence is empty.

../../_images/isEmpty.png
Observable.some(predicate=None)

Determines whether some element of an observable sequence satisfies a condition if present, else if some items are in the sequence.

Example: result = source.some() result = source.some(lambda x: x > 3)

Keyword arguments: predicate – A function to test each element for a condition.

Returns {Observable} an observable sequence containing a single element determining whether some elements in the source sequence pass the test in the specified predicate if given, else if some items are in the sequence.