diffs property

Stream<SetDiff<T>> get diffs

Implementation

Stream<SetDiff<T>> get diffs {
  return Rx.concat([
    Stream.value(ISet<T>()),
    this,
  ]).bufferCount(2, 1).map(
    (pair) {
      switch (pair) {
        case [final before, final after]:
          return SetDiff.fromISets(
            before: before,
            after: after,
          );
        case [final last]:
          return SetDiff(
            added: ISet(),
            removed: last,
          );
        default:
          throw pair; // should not happen
      }
    },
  );
}