NullErrorObservable.cs 770 B

1234567891011121314151617181920212223242526272829
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT License.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.Reactive.Disposables;
  6. namespace ReactiveTests
  7. {
  8. public class NullErrorObservable<T> : IObservable<T>
  9. {
  10. public static readonly NullErrorObservable<T> Instance = new();
  11. private NullErrorObservable()
  12. {
  13. }
  14. public IDisposable Subscribe(IObserver<T> observer)
  15. {
  16. if (observer == null)
  17. {
  18. throw new ArgumentNullException(nameof(observer));
  19. }
  20. observer.OnError(null);
  21. return Disposable.Empty;
  22. }
  23. }
  24. }