<PackageReference Include="ReactiveUI.Primitives" Version="10.2.0" />

ReactiveUI.Primitives.Advanced.TaskCountWitness<T>

public sealed class TaskCountWitness<T> : IObserver<T>, IDisposable
Task-producing terminal sink that completes with the number of matching source values.
public Task<int> Task { get; }

Gets the task completed by this sink.

public TaskCountWitness(CancellationToken cancellationToken)

Initializes a new instance of the TaskCountWitness<T> class.

public TaskCountWitness(Func<T, bool> predicate, CancellationToken cancellationToken)

Initializes a new instance of the TaskCountWitness<T> class.

public static Task<int> CountAsync(IObservable<T> source)

Subscribes to source and completes with the observed value count.

public static Task<int> CountAsync(IObservable<T> source, CancellationToken cancellationToken)

Subscribes to source and completes with the observed value count.

public static Task<int> CountAsync(IObservable<T> source, Func<T, bool> predicate)

Subscribes to source and completes with the matching value count.

public static Task<int> CountAsync(IObservable<T> source, Func<T, bool> predicate, CancellationToken cancellationToken)

Subscribes to source and completes with the matching value count.

public void Dispose()

public void OnCompleted()

public void OnError(Exception error)

public void OnNext(T value)

public void RegisterCancellation()

Registers cancellation after construction.

public void SetSubscription(IDisposable subscription)

Assigns the source subscription.