1
0

Then.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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.Joins;
  5. using System.Threading.Tasks;
  6. namespace System.Reactive.Linq
  7. {
  8. // REVIEW: Consider moving join patterns to a separate assembly.
  9. partial class AsyncObservable
  10. {
  11. public static AsyncPlan<TResult> Then<TSource, TResult>(this IAsyncObservable<TSource> source, Func<TSource, TResult> selector)
  12. {
  13. if (source == null)
  14. throw new ArgumentNullException(nameof(source));
  15. if (selector == null)
  16. throw new ArgumentNullException(nameof(selector));
  17. return new AsyncPattern<TSource>(source).Then(selector);
  18. }
  19. public static AsyncPlan<TResult> Then<TSource, TResult>(this IAsyncObservable<TSource> source, Func<TSource, Task<TResult>> selector)
  20. {
  21. if (source == null)
  22. throw new ArgumentNullException(nameof(source));
  23. if (selector == null)
  24. throw new ArgumentNullException(nameof(selector));
  25. return new AsyncPattern<TSource>(source).Then(selector);
  26. }
  27. }
  28. }