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

Added Fluent Navigation #102

Merged
merged 62 commits into from
Nov 25, 2016
Merged

Added Fluent Navigation #102

merged 62 commits into from
Nov 25, 2016

Conversation

grahammendick
Copy link
Owner

Solves the problem of constructing links with pre-populated crumb trails. For example, how do you build a link to 'person' with the 'people' crumb populated so that back navigation works?

var stateNavigator = new StateNavigator([
  {key: 'people', route: ''}
  {key: 'person', trackCrumbTrail: true}
]);

If the user navigates from 'people' to 'person' then the crumb is populated. Fluent navigation solves the problem of manually constructing this same link. Can't just call getNavigationLink('person', {id: 10}) because that only works if the current state is 'person'. Don't want to have to navigate to 'person' state first because that changes the UI.

Fluent navigation allows navigation without changing the current state or UI. Can then access the url from the fluent context.

var link = stateNavigator.fluent()
  .navigate('people')
  .navigate('person', {id: 10})
  .url;

// link: /person?id=10&crumb=%2F
stateNavigator.navigateLink(link);

Especially useful for Navigation React Native (not released yet) where need to pre-populate the crumb trail stack when coming to the app from a notification, for example.

Want to use getLink from fluent navigator so mustn't have 'this'
reference
Means that Fluent and State navigators can call in same way
Current data passed as parameter so that navigation data can be created
from current. Like includeCurrentData in NavigationLink. Don't need it
in StateNavigator because can manually construct data from current data
Want it to be like reactive programming where each operator sets up a
new subscription, it doesn't change the current subscription. That way
multiple operators can apply to single subscription without worry.
Instead of manipulating internal state of fluent navigator, create a
fluent navigator each time with the new context. (new'ing objects is
expensive, so went with functional approach)
Tried adding fluent tests inside existing navigation tests, like
'Navigate Link', but the asserts don't match because oldState isn't
populated in fluent navigation.
Fixing up Navigation tests so there's only one 'it' with multiple
asserts instead of multiple 'its' with one assert.
NavigationDataManager was missing return type which stopped the d.ts
generation
Strings starting with * showed up in url as /*, which editor mistook for
a comment
@grahammendick grahammendick merged commit 4a51fcb into master Nov 25, 2016
@grahammendick grahammendick deleted the fluentnavigation branch November 25, 2016 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant