All you need to know about the count operator in RxJS

count(predicate?: Function): OperatorFunctionpredicate: it is a function that returns a boolean and it specifies what values are to be counted.OperatorFunction: A function that returns an observable as a number.
const source = of( 1 , 2 , 3 , 4 , 5 );const result = source.pipe(count());result.subscribe(val => console.log(val))
const numbers = of( 1 , 2 , 3 , 4 , 5 , 6 );const result = numbers.pipe(count(i => i > 3 ));result.subscribe(val => console.log(val));

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store