Skip to content

)} ,System.Collections.Generic.IEqualityComparer{--0})}

ObservableAsync.DistinctUntilChanged(IObservableAsync) method

Defined in

Type: ObservableAsync Namespace: ReactiveUI.Extensions.Async Assembly: ReactiveUI.Extensions.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

Overloads

  • 1. public static IObservableAsync<T> DistinctUntilChanged<T>(this IObservableAsync<T> @this)
  • 2. public static IObservableAsync<T> DistinctUntilChanged<T>(this IObservableAsync<T> @this, IEqualityComparer<T> equalityComparer)

1. Overload

public static IObservableAsync<T> DistinctUntilChanged<T>(this IObservableAsync<T> @this)

View source

Summary: Returns an observable sequence that emits only distinct consecutive elements, suppressing duplicates that are equal to the previous element.

Type parameters

NameDescription
TThe type of the elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.

Returns: IObservableAsync -- An observable sequence that contains only the elements from the source sequence that are not equal to their immediate predecessor.

Remarks

Elements are compared using the default equality comparer for the type T. Only consecutive duplicate elements are suppressed; non-consecutive duplicates are not affected.

2. Overload

public static IObservableAsync<T> DistinctUntilChanged<T>(this IObservableAsync<T> @this, IEqualityComparer<T> equalityComparer)

View source

Summary: Returns an observable sequence that emits elements from the source sequence only when the current element is not equal to the previous element, as determined by the specified equality comparer.

Type parameters

NameDescription
TThe type of the elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
equalityComparerIEqualityComparerAn equality comparer used to determine whether consecutive elements are considered equal.

Returns: IObservableAsync -- An observable sequence that contains only distinct consecutive elements from the source sequence, as determined by the specified equality comparer.

Remarks

Use this method to suppress consecutive duplicate elements in the sequence. Only elements that differ from their immediate predecessor, according to the provided comparer, are emitted to observers.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown if equalityComparer is null.