mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-16 11:42:52 +00:00
25 lines
765 B
C#
25 lines
765 B
C#
using System;
|
|
using System.Reactive;
|
|
using System.Reactive.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Sharp7.Rx.Extensions
|
|
{
|
|
internal static class ObservableExtensions
|
|
{
|
|
public static IObservable<Unit> Select<TSource>(this IObservable<TSource> source, Func<TSource, Task> selector)
|
|
{
|
|
return source
|
|
.Select(x => Observable.FromAsync(async () => await selector(x)))
|
|
.Concat();
|
|
}
|
|
|
|
public static IObservable<TResult> Select<TSource, TResult>(this IObservable<TSource> source, Func<TSource, Task<TResult>> selector)
|
|
{
|
|
return source
|
|
.Select(x => Observable.FromAsync(async () => await selector(x)))
|
|
.Concat();
|
|
}
|
|
}
|
|
}
|