NullErrorObservable.cs 763 B

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