pairwise
Groups pairs of consecutive emissions together and emits them as an array of two values.
Parameters
There are no parameters.
Returns
OperatorFunction<T, [T, T]>
: An Observable of pairs (as arrays) of
consecutive values from the source Observable.
Description
Puts the current value and previous value together as an array, and emits that.
The Nth emission from the source Observable will cause the output Observable
to emit an array [(N-1)th, Nth] of the previous and the current value, as a
pair. For this reason, pairwise
emits on the second and subsequent
emissions from the source Observable, but not on the first emission, because
there is no previous value in that case.
Example
On every click (starting from the second), emit the relative distance to the previous click