distinctBy<S> method

Stream<T> distinctBy<S>([
  1. S field(
    1. T event
    )?
])

use for FlowR.stream or flowr/FrViewModel.stream

.distinctBy((event) => event.foo)

Implementation

Stream<T> distinctBy<S>([S Function(T event)? field]) {
  if (field == null) return distinct();
  return map(
    (e) => (e, field(e)),
  ).distinct((p, c) => p.$2 == c.$2).map((event) => event.$1);
}