Skip to content

Commit 6628923

Browse files
committed
better cancellation
1 parent 46d6bd9 commit 6628923

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/browser-router.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ export default class BrowserRouter extends Router {
3737
};
3838
}
3939
async navigate(path, ctx = new Context()) {
40-
// TODO: better cancellation
41-
if (this.router.isRunning) this.router.cancel();
40+
// if (this.router.isRunning) this.router.cancel(false);
4241
const { redirect, error } = await this.router.resolve({ path, ctx });
4342
if (error === null) {
4443
if (redirect) {
@@ -47,7 +46,7 @@ export default class BrowserRouter extends Router {
4746
this.history.push(path);
4847
}
4948
} else {
50-
this.history.push(path);
49+
if (error.message !== 'Cancelled') this.history.push(path);
5150
}
5251
}
5352
async push(path) {
@@ -72,7 +71,6 @@ export default class BrowserRouter extends Router {
7271
}
7372
private _locationChanged = async ({ pathname, hash, search }, historyAction) => {
7473
const path = pathname + search + hash;
75-
// TODO: better cancellation
7674
if (this.router.isRunning) this.router.cancel();
7775
let { location, route, status, params, redirect, result, ctx, error } = await this.router.run({ path });
7876
if (error && error.message === 'Cancelled') return;

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ object-assign@^4.1.0:
1010
version "4.1.1"
1111
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
1212

13-
path-to-regexp@^1.6.0:
13+
path-to-regexp@^1.7.0:
1414
version "1.7.0"
1515
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
1616
dependencies:
1717
isarray "0.0.1"
1818

19-
query-string@^4.2.3:
19+
query-string@^4.3.2:
2020
version "4.3.2"
2121
resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.2.tgz#ec0fd765f58a50031a3968c2431386f8947a5cdd"
2222
dependencies:
2323
object-assign "^4.1.0"
2424
strict-uri-encode "^1.0.0"
2525

2626
27-
version "0.5.4"
28-
resolved "https://registry.yarnpkg.com/router-async/-/router-async-0.5.4.tgz#c1666746089562c125c85ccee5c5e357c0ff1a48"
27+
version "0.5.6"
28+
resolved "https://registry.yarnpkg.com/router-async/-/router-async-0.5.6.tgz#b9f05c62ef2f1659e6ce988200b53a366f73a3e2"
2929
dependencies:
30-
path-to-regexp "^1.6.0"
31-
query-string "^4.2.3"
30+
path-to-regexp "^1.7.0"
31+
query-string "^4.3.2"
3232

3333
strict-uri-encode@^1.0.0:
3434
version "1.1.0"

0 commit comments

Comments
 (0)