using System; using System.Reactive.Disposables; using System.Reactive.Subjects; using System.Threading.Tasks; namespace Wabbajack.App.Extensions { public static class IObservableExtensions { public static IObservable SelectAsync(this IObservable input, CompositeDisposable disposable, Func> func) { Subject returnObs = new(); input.Subscribe(x => Task.Run(async () => { var result = await func(x); returnObs.OnNext(result); })).DisposeWith(disposable); return returnObs; } } }