Rx.Observable.prototype.count([predicate], [thisArg])

count

Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.

参数

  1. [predicate] (Function): A function to test each element for a condition. The callback is called with the following information:
    1. the value of the element
    2. the index of the element
    3. the Observable object being subscribed
  2. [thisArg] (Any): Object to use as this when executing predicate.

返回值

(Observable): An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.

Without a predicate

With a predicate