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

Use native class instead of EmberObject.extend #65

Open
jelhan opened this issue Feb 26, 2022 · 0 comments
Open

Use native class instead of EmberObject.extend #65

jelhan opened this issue Feb 26, 2022 · 0 comments

Comments

@jelhan
Copy link
Owner

jelhan commented Feb 26, 2022

Refactor history service to a native class.

const history = Service.create({
addHistory() {
const currentURL = this.router.get('currentURL');
this.history.push(currentURL);
},
history: [],
forward: [],
goBack() {
// last element in router.history is current page
// remove it from history and apply to forward list
const currentURL = this.history.pop();
this.forward.push(currentURL);
// get the page before is our target
// remove that one also, since it's readded by transition
const previousURL = this.history.pop();
assert('There were no URLs in the browser history. Make sure a transition ocurred after `setupBrowserNavigationButtons` was called.', previousURL);
return this.router.transitionTo(previousURL);
},
goForward() {
const nextURL = this.forward.pop();
assert('backButton must be used at least once before forwardButton can be used.', nextURL);
return this.router.transitionTo(nextURL);
},
router
});

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

1 participant