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 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>(
|
public static IDisposable SimpleOneWayBind<TView, TViewModel, TProp, TOut>(
|
||||||
this TView view,
|
this TView view,
|
||||||
TViewModel? viewModel,
|
TViewModel? viewModel,
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Wabbajack.App.Extensions;
|
namespace Wabbajack.App.Extensions;
|
||||||
|
|
||||||
public static class ReactiveUIExtensions
|
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;
|
_logger = logger;
|
||||||
|
|
||||||
MessageBus.Current.Listen<ConfigureLauncher>()
|
MessageBus.Current.Listen<ConfigureLauncher>()
|
||||||
.Subscribe(v => Receive(v))
|
.Subscribe(Receive)
|
||||||
.DisposeWith(VMDisposables);
|
.DisposeWith(VMDisposables);
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
this.WhenAnyValue(v => v.InstallFolder)
|
this.WhenAnyValue(v => v.InstallFolder)
|
||||||
.SelectAsync(disposables, async folder => await manager.GetByInstallFolder(folder))
|
.SelectMany(async folder => await manager.GetByInstallFolder(folder))
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.OnUIThread()
|
||||||
.Where(v => v != null)
|
.Where(v => v != null)
|
||||||
.BindTo(this, vm => vm.Setting)
|
.BindTo(this, vm => vm.Setting)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
@ -16,7 +16,7 @@ public partial class StandardInstallationView : ScreenBase<StandardInstallationV
|
|||||||
|
|
||||||
this.WhenActivated(disposables =>
|
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);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.NextCommand, view => view.NextSlide)
|
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)
|
this.BindCommand(ViewModel, vm => vm.PlayCommand, view => view.PlaySlides)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.SimpleOneWayBind(ViewModel, vm => vm.StatusText, view => view.StatusText.Text)
|
this.OneWayBind(ViewModel, vm => vm.StatusText, view => view.StatusText.Text)
|
||||||
.DisposeWith(disposables);
|
.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);
|
.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);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -53,22 +53,22 @@ public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewMode
|
|||||||
|
|
||||||
this.WhenAnyValue(t => t.ModListPath)
|
this.WhenAnyValue(t => t.ModListPath)
|
||||||
.Where(t => t != default)
|
.Where(t => t != default)
|
||||||
.SelectAsync(disposables, async x => await LoadModList(x))
|
.SelectMany(async x => await LoadModList(x))
|
||||||
.Select(x => x)
|
.OnUIThread()
|
||||||
.ObserveOn(AvaloniaScheduler.Instance)
|
.ObserveOn(AvaloniaScheduler.Instance)
|
||||||
.BindTo(this, t => t.ModList)
|
.BindTo(this, t => t.ModList)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.WhenAnyValue(t => t.ModListPath)
|
this.WhenAnyValue(t => t.ModListPath)
|
||||||
.Where(t => t != default)
|
.Where(t => t != default)
|
||||||
.SelectAsync(disposables, async x => await LoadModListImage(x))
|
.SelectMany(async x => await LoadModListImage(x))
|
||||||
.ObserveOn(AvaloniaScheduler.Instance)
|
.OnUIThread()
|
||||||
.BindTo(this, t => t.ModListImage)
|
.BindTo(this, t => t.ModListImage)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
var settings = this.WhenAnyValue(t => t.ModListPath)
|
var settings = this.WhenAnyValue(t => t.ModListPath)
|
||||||
.SelectAsync(disposables, async v => await _stateManager.Get(v))
|
.SelectMany(async v => await _stateManager.Get(v))
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.OnUIThread()
|
||||||
.Where(s => s != null);
|
.Where(s => s != null);
|
||||||
|
|
||||||
settings.Select(s => s!.Install)
|
settings.Select(s => s!.Install)
|
||||||
|
Loading…
Reference in New Issue
Block a user