parititon<T> static method

PartitionedStream<T> parititon<T>(
  1. Stream<T> source,
  2. bool predicate(
    1. T event
    )
)

Splits the source Observable into two, one with values that satisfy a predicate, and another with values that don't satisfy the predicate.

Implementation

static PartitionedStream<T> parititon<T>(
  Stream<T> source,
  bool Function(T event) predicate,
) {
  bool Function(T) not(bool Function(T event) test) =>
      (event) => !test(event);

  final stream = source.isBroadcast ? source : source.share();

  return PartitionedStream(
    stream.where(predicate),
    stream.where(not(predicate)),
  );
}