Skip to content

Support disposal for router #598

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
gaearon opened this issue Dec 12, 2014 · 5 comments
Closed

Support disposal for router #598

gaearon opened this issue Dec 12, 2014 · 5 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Dec 12, 2014

I propose router has a dispose() method that stop sending events to run and cancels any pending transactions for good. Once a router is disposed, you can't use it anymore.

One use-case for this is non-global routers (although personally I don't need this).

My use case is first-class support for hot reloading for routes. This is already possible with react-hot-loader and a bit of trickery in index.js:

// some irrelevant code removed, see #606 instead

It is however slightly inconvenient to maintain isDisposed and effectively old routers keep hanging in memory potentially even reacting to location changes. Adding a dispose method to router would solve this.

@gaearon
Copy link
Contributor Author

gaearon commented Dec 14, 2014

On a second thought, all I need is to be able to change routes mid flight.

@gaearon
Copy link
Contributor Author

gaearon commented Dec 14, 2014

@mjackson @rpflorence

How do you feel about me proceeding with #606? I can add tests and docs if you don't mind having this. This enables a better hot loading experience and can also be useful for things like #547 where people want to tear down the router.

@ryanflorence
Copy link
Member

I just merged 6417285 which is kinda related

@gaearon
Copy link
Contributor Author

gaearon commented Dec 16, 2014

Yup, thanks! I'll rebase.

@mjackson
Copy link
Member

@gaearon Yes, please! Let's follow up in #606

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants