Skip to content

Commit

Permalink
fix RoutingState test (#3047)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman committed Nov 30, 2021
1 parent d91e273 commit 05e5ffb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/ReactiveUI.Tests/Routing/RoutingStateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void NavigateAndResetCheckNavigationStack()
/// <summary>
/// Schedulers the is used for all commands.
/// </summary>
[Fact(Skip = "Wait until merged with main and ReactiveCommand update has been committed")]
[Fact]
public void SchedulerIsUsedForAllCommands()
{
var scheduler = new TestScheduler();
Expand Down
38 changes: 24 additions & 14 deletions src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public static class ReactiveCommand
observer.OnCompleted();
return Disposable.Empty;
}),
canExecute ?? Observables.True);
canExecute ?? Observables.True,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -147,7 +148,8 @@ public static class ReactiveCommand
observer.OnCompleted();
return Disposable.Empty;
}),
canExecute ?? Observables.True);
canExecute ?? Observables.True,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -187,7 +189,8 @@ public static class ReactiveCommand
observer.OnCompleted();
return Disposable.Empty;
}),
canExecute ?? Observables.True);
canExecute ?? Observables.True,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -230,7 +233,8 @@ public static class ReactiveCommand
observer.OnCompleted();
return Disposable.Empty;
}),
canExecute ?? Observables.True);
canExecute ?? Observables.True,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -298,7 +302,8 @@ public static class ReactiveCommand

return new ReactiveCommand<Unit, TResult>(
_ => execute(),
canExecute ?? Observables.True);
canExecute ?? Observables.True,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -334,7 +339,8 @@ public static class ReactiveCommand

return new ReactiveCommand<TParam, TResult>(
execute,
canExecute ?? Observables.True);
canExecute ?? Observables.True,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -365,7 +371,7 @@ public static class ReactiveCommand
throw new ArgumentNullException(nameof(execute));
}

return CreateFromObservable(() => execute().ToObservable(), canExecute);
return CreateFromObservable(() => execute().ToObservable(), canExecute, outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -396,7 +402,7 @@ public static class ReactiveCommand
throw new ArgumentNullException(nameof(execute));
}

return CreateFromObservable(() => Observable.FromAsync(execute), canExecute);
return CreateFromObservable(() => Observable.FromAsync(execute), canExecute, outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -424,7 +430,7 @@ public static class ReactiveCommand
throw new ArgumentNullException(nameof(execute));
}

return CreateFromObservable(() => execute().ToObservable(), canExecute);
return CreateFromObservable(() => execute().ToObservable(), canExecute, outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -452,7 +458,7 @@ public static class ReactiveCommand
throw new ArgumentNullException(nameof(execute));
}

return CreateFromObservable(() => Observable.FromAsync(execute), canExecute);
return CreateFromObservable(() => Observable.FromAsync(execute), canExecute, outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -488,7 +494,8 @@ public static class ReactiveCommand

return CreateFromObservable<TParam, TResult>(
param => execute(param).ToObservable(),
canExecute);
canExecute,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -524,7 +531,8 @@ public static class ReactiveCommand

return CreateFromObservable<TParam, TResult>(
param => Observable.FromAsync(ct => execute(param, ct)),
canExecute);
canExecute,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -557,7 +565,8 @@ public static class ReactiveCommand

return CreateFromObservable<TParam, Unit>(
param => execute(param).ToObservable(),
canExecute);
canExecute,
outputScheduler);
}

/// <summary>
Expand Down Expand Up @@ -590,7 +599,8 @@ public static class ReactiveCommand

return CreateFromObservable<TParam, Unit>(
param => Observable.FromAsync(ct => execute(param, ct)),
canExecute);
canExecute,
outputScheduler);
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/ReactiveUI/Routing/RoutingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ private void SetupRx()
() =>
{
NavigationStack.RemoveAt(NavigationStack.Count - 1);
return Observable.Return(NavigationStack.Count > 0 ? NavigationStack[NavigationStack.Count - 1] : default);
return Observable.Return(NavigationStack.Count > 0 ? NavigationStack[NavigationStack.Count - 1] : default).ObserveOn(navigateScheduler);
},
countAsBehavior.Select(x => x > 1),
navigateScheduler);
countAsBehavior.Select(x => x > 1));

Navigate = ReactiveCommand.CreateFromObservable<IRoutableViewModel, IRoutableViewModel>(
vm =>
Expand All @@ -112,9 +111,8 @@ private void SetupRx()
}
NavigationStack.Add(vm);
return Observable.Return(vm);
},
outputScheduler: navigateScheduler);
return Observable.Return(vm).ObserveOn(navigateScheduler);
});

NavigateAndReset = ReactiveCommand.CreateFromObservable<IRoutableViewModel, IRoutableViewModel>(
vm =>
Expand Down

0 comments on commit 05e5ffb

Please sign in to comment.