RxJS bufferCount() Transformation OperatorThe RxJS bufferCount() operator is a transformation operator that buffers the source Observable values until the size hits the maximum bufferSize given. In other words, we can say that the bufferCount() operator collects the values from the past as an array, and emits that array only when the size reaches bufferSize. It takes two arguments:
Syntax:Following is the syntax of the bufferCount() operator: Parameter ExplanationbufferSize: It specifies the size of the buffer to be emitted. Return valueThe bufferCount() operator's return value is an Observable of arrays of buffered values. Let us see some examples of bufferCount() operator to understand it clearly. Example 1 (Collect buffer and emit after specified number of values)Output: After executing the above example, you will see the following result: Example 2 (Overlapping buffers)Output: After executing the above example, you will see the following result:
Next TopicRxJS Operators
|