mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Remove SelectAsync, replace with SelectMany
This commit is contained in:
parent
295b629169
commit
0334a4f217
@ -11,21 +11,6 @@ namespace Wabbajack.App.Extensions;
|
||||
|
||||
public static class IObservableExtensions
|
||||
{
|
||||
public static IObservable<TOut> SelectAsync<TIn, TOut>(this IObservable<TIn> input,
|
||||
CompositeDisposable disposable,
|
||||
Func<TIn, ValueTask<TOut>> func)
|
||||
{
|
||||
Subject<TOut> returnObs = new();
|
||||
|
||||
input.Subscribe(x => Task.Run(async () =>
|
||||
{
|
||||
var result = await func(x);
|
||||
returnObs.OnNext(result);
|
||||
})).DisposeWith(disposable);
|
||||
|
||||
return returnObs;
|
||||
}
|
||||
|
||||
public static IDisposable SimpleOneWayBind<TView, TViewModel, TProp, TOut>(
|
||||
this TView view,
|
||||
TViewModel? viewModel,
|
||||
|
@ -1,5 +1,14 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Wabbajack.App.Extensions;
|
||||
|
||||
public static class ReactiveUIExtensions
|
||||
{
|
||||
public static IObservable<T> OnUIThread<T>(this IObservable<T> src)
|
||||
{
|
||||
return src.ObserveOn(AvaloniaScheduler.Instance);
|
||||
}
|
||||
}
|
@ -35,14 +35,14 @@ public class LauncherViewModel : ViewModelBase
|
||||
_logger = logger;
|
||||
|
||||
MessageBus.Current.Listen<ConfigureLauncher>()
|
||||
.Subscribe(v => Receive(v))
|
||||
.Subscribe(Receive)
|
||||
.DisposeWith(VMDisposables);
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.WhenAnyValue(v => v.InstallFolder)
|
||||
.SelectAsync(disposables, async folder => await manager.GetByInstallFolder(folder))
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.SelectMany(async folder => await manager.GetByInstallFolder(folder))
|
||||
.OnUIThread()
|
||||
.Where(v => v != null)
|
||||
.BindTo(this, vm => vm.Setting)
|
||||
.DisposeWith(disposables);
|
||||
|
@ -16,7 +16,7 @@ public partial class StandardInstallationView : ScreenBase<StandardInstallationV
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.Slide.Image, view => view.SlideImage.Source)
|
||||
this.OneWayBind(ViewModel, vm => vm.Slide.Image, view => view.SlideImage.Source)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.NextCommand, view => view.NextSlide)
|
||||
@ -31,13 +31,13 @@ public partial class StandardInstallationView : ScreenBase<StandardInstallationV
|
||||
this.BindCommand(ViewModel, vm => vm.PlayCommand, view => view.PlaySlides)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.SimpleOneWayBind(ViewModel, vm => vm.StatusText, view => view.StatusText.Text)
|
||||
this.OneWayBind(ViewModel, vm => vm.StatusText, view => view.StatusText.Text)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.SimpleOneWayBind(ViewModel, vm => vm.StepsProgress, view => view.StepsProgress.Value, p => p.Value * 1000)
|
||||
this.OneWayBind(ViewModel, vm => vm.StepsProgress, view => view.StepsProgress.Value, p => p.Value * 1000)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.SimpleOneWayBind(ViewModel, vm => vm.StepProgress, p => p.StepProgress.Value, p => p.Value * 10000)
|
||||
this.OneWayBind(ViewModel, vm => vm.StepProgress, p => p.StepProgress.Value, p => p.Value * 10000)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
});
|
||||
|
@ -53,22 +53,22 @@ public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewMode
|
||||
|
||||
this.WhenAnyValue(t => t.ModListPath)
|
||||
.Where(t => t != default)
|
||||
.SelectAsync(disposables, async x => await LoadModList(x))
|
||||
.Select(x => x)
|
||||
.SelectMany(async x => await LoadModList(x))
|
||||
.OnUIThread()
|
||||
.ObserveOn(AvaloniaScheduler.Instance)
|
||||
.BindTo(this, t => t.ModList)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.WhenAnyValue(t => t.ModListPath)
|
||||
.Where(t => t != default)
|
||||
.SelectAsync(disposables, async x => await LoadModListImage(x))
|
||||
.ObserveOn(AvaloniaScheduler.Instance)
|
||||
.SelectMany(async x => await LoadModListImage(x))
|
||||
.OnUIThread()
|
||||
.BindTo(this, t => t.ModListImage)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
var settings = this.WhenAnyValue(t => t.ModListPath)
|
||||
.SelectAsync(disposables, async v => await _stateManager.Get(v))
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.SelectMany(async v => await _stateManager.Get(v))
|
||||
.OnUIThread()
|
||||
.Where(s => s != null);
|
||||
|
||||
settings.Select(s => s!.Install)
|
||||
|
Loading…
Reference in New Issue
Block a user