Skip to content

Commit 8ef6171

Browse files
committed
feat: increase default timeout, expose as prop
1 parent 5259773 commit 8ef6171

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ Whether to prefetch the matched route component.
6666

6767
A list of additional files to prefetch. By default we only prefetch the route component.
6868

69+
### timeout
70+
71+
- Type: `number`
72+
- Default: `2000` (ms)
73+
74+
Timeout after which prefetching will occur.
75+
6976
## Credits
7077

7178
Inspired by [quicklink](https://github.com/GoogleChromeLabs/quicklink) and [`nuxt-link`](https://github.com/nuxt/nuxt.js/pull/4574/).

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ function installRouterPrefetch(Vue, { componentName = 'RouterLink' } = {}) {
4444
},
4545
prefetchFiles: {
4646
type: Array
47+
},
48+
timeout: {
49+
type: Number,
50+
default: 2000
4751
}
4852
},
4953
mounted() {
5054
if (this.prefetch && observer && canPrefetch) {
51-
requestIdleCallback(this.observe, { timeout: 1000 })
55+
requestIdleCallback(this.observe, { timeout: this.timeout })
5256
}
5357
},
5458
beforeDestory() {

0 commit comments

Comments
 (0)