toStateStream method

StateStream<T> toStateStream(
  1. T value, {
  2. Equality<T>? equals,
})

Convert this Stream to a StateStream.

Returned stream acts like Stream.distinct except it provides seed value used to check for equality, and synchronous access to the last emitted item.

Data events are skipped if they are equal to the previous data event. Equality is determined by the provided equals method. If that is omitted, the '==' operator on the last provided data element is used.

This stream is a single-subscription stream.

Implementation

StateStream<T> toStateStream(
  T value, {
  Equality<T>? equals,
}) =>
    _StateStream(this, value, equals ?? StateStream.defaultEquality);