Table of Contents

Class DistinctUntilChanged

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an operator that returns only distinct contiguous elements of an observable sequence.

Marble diagram

The DistinctUntilChanged operator removes all contiguous elements in the sequence that are equal. Equality is determined by the default EqualityComparer<T> for the type of the elements in the source sequence.

In other words, after each element is emitted by the result sequence, subsequent elements will be dropped until the value changes.

Example

Use DistinctUntilChanged to filter only elements which are distinct from the previous element.

DistinctUntilChanged Example

Signal State Transitions

Use DistinctUntilChanged to signal changes in state, such as when an object enters or leaves a region of interest.

DistinctUntilChanged Application StateTransitions

Note

This example requires the Bonsai.WindowsInput package to be installed.

public class DistinctUntilChanged : Combinator
Inheritance
DistinctUntilChanged
Inherited Members

Methods

Process<TSource>(IObservable<TSource>)

Returns an observable sequence that contains only distinct contiguous elements.