Skip to content
Permalink
Browse files

fix: NavigateBack ObserveOn Router Scheduler (#2315)

* fix: NavigateBack ObserveOn Router Scheduler

* Skipping breaking Winform tests #2279
  • Loading branch information
RLittlesII committed Jan 17, 2020
1 parent 64f8ae3 commit ab3feed9335e932728f7b17a3696ac009a83f467
@@ -18,7 +18,7 @@ namespace ReactiveUI.Tests.Winforms
{
public class DefaultPropertyBindingTests
{
[Fact]
[Fact(Skip = "https://github.com/reactiveui/ReactiveUI/issues/2279")]
public void WinformsCreatesObservableForPropertyWorksForTextboxes()
{
var input = new TextBox();
@@ -42,7 +42,7 @@ public void WinformsCreatesObservableForPropertyWorksForTextboxes()
Assert.Equal(1, output.Count);
}

[Fact]
[Fact(Skip = "https://github.com/reactiveui/ReactiveUI/issues/2279")]
public void WinformsCreatesObservableForPropertyWorksForComponents()
{
var input = new ToolStripButton(); // ToolStripButton is a Component, not a Control
@@ -67,7 +67,7 @@ public void WinformsCreatesObservableForPropertyWorksForComponents()
Assert.Equal(1, output.Count);
}

[Fact]
[Fact(Skip = "https://github.com/reactiveui/ReactiveUI/issues/2279")]
public void WinformsCreatesObservableForPropertyWorksForThirdPartyControls()
{
var input = new AThirdPartyNamespace.ThirdPartyControl();
@@ -91,7 +91,7 @@ public void WinformsCreatesObservableForPropertyWorksForThirdPartyControls()
Assert.Equal(1, output.Count);
}

[Fact]
[Fact(Skip = "https://github.com/reactiveui/ReactiveUI/issues/2279")]
public void CanBindViewModelToWinformControls()
{
var vm = new FakeWinformViewModel();
@@ -113,7 +113,7 @@ public void CanBindViewModelToWinformControls()
Assert.Equal(vm.SomeDouble.ToString(), view.Property3.Text);
}

[Fact]
[Fact(Skip = "https://github.com/reactiveui/ReactiveUI/issues/2279")]
public void SmokeTestWinformControls()
{
var vm = new FakeWinformViewModel();
@@ -1,4 +1,4 @@
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
@@ -56,7 +56,13 @@ public RoutedViewHost()
})
.Subscribe());

var previousCount = this.WhenAnyObservable(x => x.Router.NavigationChanged).CountChanged().Select(_ => Router.NavigationStack.Count).StartWith(Router.NavigationStack.Count);
var previousCount =
this.WhenAnyObservable(x => x.Router.NavigationChanged)
.CountChanged()
.ObserveOn(Router.Scheduler)
.Select(_ => Router.NavigationStack.Count)
.StartWith(Router.NavigationStack.Count);

var currentCount = previousCount.Skip(1);

d(Observable.Zip(previousCount, currentCount, (previous, current) => new { Delta = previous - current, Current = current })
@@ -140,7 +146,10 @@ public RoutedViewHost()

try
{
Router.NavigationStack.RemoveAt(Router.NavigationStack.Count - 1);
if (Router.NavigationStack.Count > 1)
{
Router.NavigationStack.RemoveAt(Router.NavigationStack.Count - 1);
}
}
finally
{
@@ -150,7 +159,6 @@ public RoutedViewHost()
((IViewFor)CurrentPage).ViewModel = Router.GetCurrentViewModel();
}));
}));

var screen = Locator.Current.GetService<IScreen>();
if (screen == null)
{
@@ -161,22 +169,22 @@ public RoutedViewHost()

this.WhenAnyValue(x => x.Router)
.SelectMany(router =>
{
return router.NavigationStack.ToObservable()
.Select(x => (Page)ViewLocator.Current.ResolveView(x))
.SelectMany(x => PushAsync(x).ToObservable())
.Finally(() =>
{
var vm = router.GetCurrentViewModel();
if (vm == null)
router
.NavigationStack
.ToObservable()
.Select(x => (Page)ViewLocator.Current.ResolveView(x))
.SelectMany(x => PushAsync(x).ToObservable())
.Finally(() =>
{
return;
}
var vm = router.GetCurrentViewModel();
if (vm == null)
{
return;
}

((IViewFor)CurrentPage).ViewModel = vm;
CurrentPage.Title = vm.UrlPathSegment;
});
})
((IViewFor)CurrentPage).ViewModel = vm;
CurrentPage.Title = vm.UrlPathSegment;
}))
.Subscribe();
}

0 comments on commit ab3feed

Please sign in to comment.
You can’t perform that action at this time.