question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing parameters back

See original GitHub issue

I’m trying to understand how the new navigation works in 10.2. What I’m trying to do is this:

  1. Navigate to ListPage.
  2. Navigate to DetailPage.
  3. Navigate to EditPage.
  4. Navigate back to DetailPage.

From my ListPageViewModel I create my path and navigate:

public async void ViewItem(Item item)
{
    // _navigationService.GetNavigationPath(true) = "/ListPage".
    var path = PathBuilder.Create(nameof(DetailPage), ("itemId", item.Id)).ToString();
    await _navigationService.NavigateAsync(path, null, new DrillInNavigationTransitionInfo());
}

Then, to edit the item from my DetailPageViewModel:

public async void EditItem(Item item)
{
    // _navigationService.GetNavigationPath(true) = "/DetailPage?itemId=5cfb0eda-cdbd-4b08-b29b-dff2ef07ea77/ListPage?"
    var path = PathBuilder.Create(nameof(EditPage), ("itemId", item.Id)).ToString();
    await _navigationService.NavigateAsync(path);
}

First off, that path seems really strange to me. According to #1620, performing this nested navigation manually would look like “/ListPage/DetailPage?itemId=5cfb0eda-cdbd-4b08-b29b-dff2ef07ea77”, so I don’t understand why my url looks so weird here. But all the same, the navigation does work correctly.

However, when I go back, in my DetailPageViewModel

public override void OnNavigatedTo(INavigationParameters parameters)
{
    // _navigationService.GetNavigationPath(true) = "/EditPage?itemId=5cfb0eda-cdbd-4b08-b29b-dff2ef07ea77/ListPage?"
    var itemId = parameters.GetValue<string>("itemId");    // parameters is empty.
}

Once again, that path seems extremely strange. “DetailPage” isn’t even present. Also, I don’t get my id parameter handed to my DetailPageViewModel again, as I would expect to. Of course, this means my app crashes or doesn’t perform correctly since it can’t find the necessary data.

Am I grossly misunderstanding how this is supposed to work, or is this broken?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JerryNixoncommented, Mar 21, 2018

@TastesLikeTurkey Create a new issue if you see anything else.

0reactions
ShawnTheBeachycommented, Mar 21, 2018

@JerryNixon Glad I could help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parameter Passing Techniques in C/C++
1. Pass by Result ... This method uses out-mode semantics. Just before control is transferred back to the caller, the value of the...
Read more >
JavaScript: Passing parameters to a callback function
When you have a callback that will be called by something other than your code with a specific number of params and you...
Read more >
Passing parameters to routes
Pass params to a route by putting them in an object as a second parameter to the navigation.navigate function: navigation.navigate('RouteName', { /* params...
Read more >
Passing In Parameters And Returning Types in C# | ...
Objective: Pass parameters into and return variables from methods. ; void Update() ; public void Damage(int damageAmount) ; public int getHealth() ...
Read more >
Passing Parameters to a Method & Returning Values - YouTube
Get more lessons like this at http://www.MathTutorDVD.com Learn how to program in java with our online tutorial. We will cover variables, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found