-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Reset prefetchCache when reloading a route. #617
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { parse, format } from 'url' | |
| import evalScript from '../eval-script' | ||
| import shallowEquals from '../shallow-equals' | ||
| import { EventEmitter } from 'events' | ||
| import { reloadIfPrefetched } from '../prefetch' | ||
|
|
||
| export default class Router extends EventEmitter { | ||
| constructor (pathname, query, { Component, ErrorComponent, ctx } = {}) { | ||
|
|
@@ -77,6 +78,7 @@ export default class Router extends EventEmitter { | |
|
|
||
| async reload (route) { | ||
| delete this.components[route] | ||
| await reloadIfPrefetched(route) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to do anything for normal HMR since the page gets updated via HMR. We need to do this, because we are removing the page from the cache and loading a error page instead. |
||
|
|
||
| if (route !== this.route) return | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have only the promise version of the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! That's true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.