-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
RFC: router.stop() and router.setOptions() #606
Conversation
To clarify, this is my use case: 'use strict';
var routes = require('./routes'),
Router = require('react-router');
var router = Router.create({
routes: routes,
location: Router.HistoryLocation
});
function render(Handler, state) {
// ...
}
router.run(render);
// this is webpack's hot module reloading:
module.hot.accept('./routes', function () {
routes = require('./routes'); // obtain new version of the module
router.stop();
router.setOptions({ routes: routes });
router.run(render);
}); Probably, a better API would be to have Also Thoughts? |
I added |
+1 for this, I have a very similar use case. |
I think I like this. A little busy at the moment to spend a lot of thought on it personally, but please keep this conversation going :) |
OK, I'll do my best to add some tests later this week! |
+1. this is definitely needed for hot reloading after the API changes |
I don't think I'm going to have the time this week to write the tests, and later I'm on holiday. |
@mjackson Do you think |
@gaearon I've tried as hard as I can thus far to avoid passing an "options" hash to Anyway, just my opinion obviously. Feel free to disagree :) |
I see your point now! Let's proceed with |
This commit adds a router.stop() method that may be used to prevent a router from listening to further changes to location. This method is also called automatically when a router component is removed from the DOM. Thanks to @gaearon and @rpflorence for the initial thrust to get this functionality into the router. This work doesn't entirely supercede #606, but duplicates much of the work done there.
Let's do it later! I'm on a vacation now and can do |
@gaearon Sounds good. Enjoy your holiday! :) |
No description provided.