-
-
Save mitchlloyd/9def667b38a8da9558d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in instance-initializers/boot-history.js | |
// | |
// Not sure if this would work, but it would be interesting to see if | |
// this would let the history service capture the first willTransition | |
// event. | |
export function initialize(application) { | |
application.container.lookup('service:history'); | |
} | |
export default { | |
name: 'boot-history', | |
initialize: initialize | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { inject } = Ember; | |
export default Ember.Service.extend({ | |
routing: inject.service('-routing'), | |
// whatever stuff is already here | |
init() { | |
this._super(...arguments); | |
this.get('routing.router').on('willTransition', (t) => this.capture(t)); | |
}, | |
goBack() { | |
let previousTransition = this.get('previous'); | |
if (previousTransition) { | |
this.capture(previousTransition); | |
previousTransition.retry(); | |
} else { | |
this.get('routing').transitionTo('home'); | |
} | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment