<PackageReference Include="System.Reactive" Version="5.0.0" />

CombineLatest<T1, T2, T3, TResult>

sealed class CombineLatest<T1, T2, T3, TResult> : Producer<TResult, _<T1, T2, T3, TResult>>
using System.Reactive.Disposables; using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1, 1, 1, 1, 1, 1 })] internal sealed class CombineLatest<[System.Runtime.CompilerServices.Nullable(2)] T1, [System.Runtime.CompilerServices.Nullable(2)] T2, [System.Runtime.CompilerServices.Nullable(2)] T3, [System.Runtime.CompilerServices.Nullable(2)] TResult> : Producer<TResult, CombineLatest<T1, T2, T3, TResult>._> { [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class _ : CombineLatestSink<TResult> { private readonly Func<T1, T2, T3, TResult> _resultSelector; private readonly CombineLatestObserver<T1> _observer1; private readonly CombineLatestObserver<T2> _observer2; private readonly CombineLatestObserver<T3> _observer3; public _(Func<T1, T2, T3, TResult> resultSelector, IObserver<TResult> observer) : base(3, observer) { _resultSelector = resultSelector; _observer1 = new CombineLatestObserver<T1>(_gate, this, 0); _observer2 = new CombineLatestObserver<T2>(_gate, this, 1); _observer3 = new CombineLatestObserver<T3>(_gate, this, 2); } public void Run(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3) { IDisposable[] disposables = new IDisposable[3] { _observer1, _observer2, _observer3 }; _observer1.SetResource(ObservableExtensions.SubscribeSafe<T1>(source1, (IObserver<T1>)_observer1)); _observer2.SetResource(ObservableExtensions.SubscribeSafe<T2>(source2, (IObserver<T2>)_observer2)); _observer3.SetResource(ObservableExtensions.SubscribeSafe<T3>(source3, (IObserver<T3>)_observer3)); SetUpstream(StableCompositeDisposable.CreateTrusted(disposables)); } protected override TResult GetResult() { return _resultSelector(_observer1.Value, _observer2.Value, _observer3.Value); } } private readonly IObservable<T1> _source1; private readonly IObservable<T2> _source2; private readonly IObservable<T3> _source3; private readonly Func<T1, T2, T3, TResult> _resultSelector; public CombineLatest(IObservable<T1> source1, IObservable<T2> source2, IObservable<T3> source3, Func<T1, T2, T3, TResult> resultSelector) { _source1 = source1; _source2 = source2; _source3 = source3; _resultSelector = resultSelector; } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 0, 0, 0 })] protected override _ CreateSink(IObserver<TResult> observer) { return new _(_resultSelector, observer); } protected override void Run([System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 0, 0, 0 })] _ sink) { sink.Run(_source1, _source2, _source3); } } }