zeroasterisk/MeteorRider — pull request #15 by cdoe (2014-04-07 20:38:23+00:00)
Title: pass currentPath to persist through hot code reload

I was having trouble with the current route not persisting through a hot code reload. I came up with a quick solution that seems to fix the problem. Is this the right way to go about it?

In `phonegapapp.js`, accept a `currentPath` parameter and pass to `MeteorRider.init()`:

``` javascript
phonegapapp = {
...
meteorRider: function(currentPath) {
currentPath = typeof currentPath !== 'undefined' ? currentPath : '';
MeteorRider.init(currentPath);
}
}
```

Receive `currentPath` within `meteor-rider.js` and use in `window.history.replaceState()`:

``` javascript
var MeteorRider = {
init: function(currentPath) {
...
// trigger request
$.ajax({
...
success: function( data, textStatus, jqXHR ) {
...
window.history.replaceState({}, "", meteorUrl + currentPath);
}
});
}
}
```

And then, in the `Meteor.startup()` function, simply pass the current route (I'm using Iron-Router):

``` javascript
if(typeof phonegapapp !== 'undefined'){
Meteor._reload.onMigrate('phonegapapp', function(){
phonegapapp.meteorRider(Router.current().path);
return [false];
});
};
```