partition
Splits the source Observable into two, one with values that satisfy a predicate, and another with values that don't satisfy the predicate.
Parameters
Returns
UnaryFunction<Observable<T>, [Observable<T>, Observable<T>]>
: An array with two Observables: one
with values that passed the predicate, and another with values that did not
pass the predicate.
Description
It's like filter
, but returns two Observables:
one like the output of filter
, and the other with values that did not
pass the condition.
partition
outputs an array with two Observables that partition the values
from the source Observable through the given predicate
function. The first
Observable in that array emits source values for which the predicate argument
returns true. The second Observable emits source values for which the
predicate returns false. The first behaves like filter
and the second
behaves like filter
with the predicate negated.
Example
Partition click events into those on DIV elements and those elsewhere