Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ToUri() to the PathBuilder #1719

Open
JerryNixon opened this issue Dec 17, 2019 · 4 comments
Open

Add ToUri() to the PathBuilder #1719

JerryNixon opened this issue Dec 17, 2019 · 4 comments
Assignees

Comments

@JerryNixon
Copy link
Member

Currently has ToString() which requires:

var path = PathBuilder.Create(BackStackBehaviors.Clear, nameof(MyView)).ToString();
await NavigationService.NavigateAsync(new Uri(path, UriKind.Relative));

This works and should not be changed.

The desired ADDITIONAL syntax would be:

var path = PathBuilder.Create(BackStackBehaviors.Clear, nameof(MyView)).ToUri();
await NavigationService.NavigateAsync(path);

It will be difficult to remember the UriKind.Relative part anyway.

@JerryNixon JerryNixon self-assigned this Dec 17, 2019
@JerryNixon JerryNixon changed the title Add ToUri() to the PathBuilder Add ToUri() to the PathBuilder Dec 17, 2019
@JerryNixon
Copy link
Member Author

An alternative is to allow NavigationService.NavigateAsync to accept PathBuilder as an argument. This would not only NOT require creating the Uri by the developer, but also drive them toward the type.

@darenm
Copy link
Contributor

darenm commented Dec 17, 2019

Once a dev creates a PathBuilder instance using this method - are they likely to do anything to it? Or does it exist solely to create a string/(or Uri) that is then passed into NavigateAsync? If the latter, then why not have the below and save the need to create another object entirely:

await NavigationService.NavigateAsync(BackStackBehaviors.Clear, nameof(MyView));

@JerryNixon
Copy link
Member Author

You might also use the PathBuilder if you are putting a payload inside a JumpList or a Tile or inside a Toast so that you can use that payload to preload the Frame after you activate the app. I still think the best approach here is to simply allow NavigateAsync to accept PathBuilder as an argument.

var path = PathBuilder.Create(BackStackBehaviors.Clear, nameof(MyView));
await NavigationService.NavigateAsync(path, {extra in-memory parameters});

I don't see a downside to ALSO implementing ToUri() while we are in there.

@JerryNixon
Copy link
Member Author

I wonder if a fluent API would be useful here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants