Skip to content

Commit

Permalink
Merge pull request reactiveui#1115 from kentcb/icanactivate-for-XF-ac…
Browse files Browse the repository at this point in the history
…tivation-for-view-fetcher

Add support for ICanActivate.
  • Loading branch information
kentcb authored Jun 24, 2016
2 parents 7d64916 + 39047a7 commit fe66f9c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ReactiveUI.XamForms/XamForms/ActivationForViewFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public int GetAffinityForView(Type view)
public IObservable<bool> GetActivationForView(IActivatable view)
{
var activation =
GetActivationFor(view as ICanActivate) ??
GetActivationFor(view as Page) ??
GetActivationFor(view as View) ??
GetActivationFor(view as Cell) ??
Expand All @@ -28,6 +29,17 @@ public IObservable<bool> GetActivationForView(IActivatable view)
return activation.DistinctUntilChanged();
}

private static IObservable<bool> GetActivationFor(ICanActivate canActivate)
{
if (canActivate == null) {
return null;
}

return Observable.Merge(
canActivate.Activated.Select(_ => true),
canActivate.Deactivated.Select(_ => false));
}

private static IObservable<bool> GetActivationFor(Page page)
{
if (page == null) {
Expand Down

0 comments on commit fe66f9c

Please sign in to comment.