mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ModListMetadataVM FlowSwitch on exists check
This commit is contained in:
parent
bc6580c846
commit
8ae8e28f67
@ -40,7 +40,7 @@ namespace Wabbajack
|
||||
/// <param name="source">Source observable to subscribe to if on</param>
|
||||
/// <param name="filterSwitch">On/Off signal of whether to subscribe to source observable</param>
|
||||
/// <returns>Observable that publishes data from source, if the switch is on.</returns>
|
||||
public static IObservable<T> FilterSwitch<T>(this IObservable<T> source, IObservable<bool> filterSwitch)
|
||||
public static IObservable<T> FlowSwitch<T>(this IObservable<T> source, IObservable<bool> filterSwitch)
|
||||
{
|
||||
return filterSwitch
|
||||
.DistinctUntilChanged()
|
||||
@ -211,7 +211,7 @@ namespace Wabbajack
|
||||
|
||||
public static IObservable<T> DelayInitial<T>(this IObservable<T> source, TimeSpan delay)
|
||||
{
|
||||
return source.FilterSwitch(
|
||||
return source.FlowSwitch(
|
||||
Observable.Return(System.Reactive.Unit.Default)
|
||||
.Delay(delay)
|
||||
.Select(_ => true)
|
||||
@ -220,7 +220,7 @@ namespace Wabbajack
|
||||
|
||||
public static IObservable<T> DelayInitial<T>(this IObservable<T> source, TimeSpan delay, IScheduler scheduler)
|
||||
{
|
||||
return source.FilterSwitch(
|
||||
return source.FlowSwitch(
|
||||
Observable.Return(System.Reactive.Unit.Default)
|
||||
.Delay(delay, scheduler)
|
||||
.Select(_ => true)
|
||||
|
@ -109,7 +109,7 @@ namespace Wabbajack
|
||||
|
||||
_exists = Observable.Interval(TimeSpan.FromSeconds(3), RxApp.TaskpoolScheduler)
|
||||
// Only check exists on timer if desired
|
||||
.FilterSwitch(doExistsCheck)
|
||||
.FlowSwitch(doExistsCheck)
|
||||
.Unit()
|
||||
// Also check though, when fields change
|
||||
.Merge(this.WhenAny(x => x.PathType).Unit())
|
||||
|
@ -25,12 +25,19 @@ namespace Wabbajack
|
||||
public ViewModel NavigateBackTarget { get; set; }
|
||||
public ReactiveCommand<Unit, Unit> BackCommand { get; protected set; }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<bool> _IsActive;
|
||||
public bool IsActive => _IsActive.Value;
|
||||
|
||||
public BackNavigatingVM(MainWindowVM mainWindowVM)
|
||||
{
|
||||
BackCommand = ReactiveCommand.Create(
|
||||
execute: () => Utils.CatchAndLog(() => mainWindowVM.NavigateTo(NavigateBackTarget)),
|
||||
canExecute: this.ConstructCanNavigateBack()
|
||||
.ObserveOnGuiThread());
|
||||
|
||||
_IsActive = mainWindowVM.WhenAny(x => x.ActivePane)
|
||||
.Select(x => object.ReferenceEquals(this, x))
|
||||
.ToProperty(this, nameof(IsActive));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ namespace Wabbajack
|
||||
(this).WhenAny(x => x.Mo2Folder)
|
||||
.DelayInitial(TimeSpan.FromMilliseconds(100))
|
||||
.Where(x => Directory.Exists(x))
|
||||
.FilterSwitch(
|
||||
.FlowSwitch(
|
||||
(this).WhenAny(x => x.DownloadLocation.Exists)
|
||||
.Invert())
|
||||
// A skip is needed to ignore the initial signal when the FilterSwitch turns on
|
||||
|
@ -107,6 +107,7 @@ namespace Wabbajack
|
||||
_Exists = Observable.Interval(TimeSpan.FromSeconds(0.5))
|
||||
.Unit()
|
||||
.StartWith(Unit.Default)
|
||||
.FlowSwitch(_parent.WhenAny(x => x.IsActive))
|
||||
.Select(_ =>
|
||||
{
|
||||
try
|
||||
|
@ -60,7 +60,7 @@ namespace Wabbajack
|
||||
// When filter switch enabled, fire an initial signal
|
||||
.StartWith(Unit.Default)
|
||||
// Only subscribe to slideshow triggers if enabled and installing
|
||||
.FilterSwitch(
|
||||
.FlowSwitch(
|
||||
Observable.CombineLatest(
|
||||
this.WhenAny(x => x.Enable),
|
||||
this.WhenAny(x => x.Installer.Installing),
|
||||
|
Loading…
Reference in New Issue
Block a user