Skip to content

Added a .back method to ui-router, fixes #92 #861

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

Closed
wants to merge 1 commit into from

Conversation

mike-tempest
Copy link

Adds $state.previous and $state.previousParams. Implements $state.back method
which wraps $state.transitionTo and can take an options object which is passed
through.

$state.previous and $state.previousParams are only updated when the transition
completes.

@mike-tempest mike-tempest mentioned this pull request Feb 4, 2014
@nateabele
Copy link
Contributor

I really think history tracking is out of scope for $state itself. That's a $location concern. Also, there appear to be several different unrelated things going on in this PR. Please group related changes into separate PRs, and be sure to follow the contributor guidelines.

@mike-tempest
Copy link
Author

It's unfortunately not a $location concern as, $location is for when url changes are occuring. In this instance we are actually wanting the feature of a $state change, as if we do not want to update the url for various reasons, a $state history is the best way round it without a hack on the state change event.

Also, there is only one thing happening in this PR. The creation of a .back method and the necessary setup of caching of the previous state and params. The rest is document updating as requested in the developer guidelines stated.

@nateabele
Copy link
Contributor

The rest is document updating as requested in the developer guidelines stated.

I'm not sure I understand. It looks like the docs were fully regenerated.

@mike-tempest
Copy link
Author

The only changes I have made are in state.js and stateSpec.js for the unit tests.

All of the rest was generated when I ran grunt dist to produce the correct documentation from my JS Doc for the new method I have created.

@nateabele
Copy link
Contributor

Yeah, we're removing the generated stuff from the repo.

@mike-tempest
Copy link
Author

OK, I was just following what looked like the normal practice. Is the PR all good now you have more information?

@timkindberg
Copy link
Contributor

I'm a bit worried devs will think this method can go back beyond just a single state. Do you think its okay that it only can go back one time?

@mike-tempest
Copy link
Author

I think it's perfectly good to only go back one state, this is the functionality people were asking for, else you would just use the go function as there would be more routes usually that could take you more than one link away. I will squash the commit and remove generated docs now.

Adds $state.previous and $state.previousParams. Implements $state.back method
which wraps $state.transitionTo and can take an options object which is passed
through.

$state.previous and $state.previousParams are only updated when the transition
completes.

Added unit tests for .back method()
@mike-tempest
Copy link
Author

@timkindberg Commits have been squashed along with removing documentation

@nateabele
Copy link
Contributor

Sorry, I still really don't think this is a good solution. Three reasons:

  • We've had just as many requests for full history management as we've had for just the ability to 'go back', and furthermore I'm sure many people who are just asking for the ability to 'go back' now will want more expanded history support later.
  • Fundamentally, history management is not a core concern of $state, which is already bloated and in need of a refactor.
  • Finally, $state is a service, services are global. The fact that it contains mutable state at all is already bad. That is not a reason to pile on more.

If you're interested in rolling your own separate History service, I'm happy to talk about implementing the necessary hooks in $state in order to make that possible, if it isn't already.

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.

3 participants