Skip to content

Commit

Permalink
feat: increase default timeout, expose as prop
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Feb 13, 2019
1 parent 5259773 commit 8ef6171
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Whether to prefetch the matched route component.

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

### timeout

- Type: `number`
- Default: `2000` (ms)

Timeout after which prefetching will occur.

## Credits

Inspired by [quicklink](https://github.com/GoogleChromeLabs/quicklink) and [`nuxt-link`](https://github.com/nuxt/nuxt.js/pull/4574/).
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ function installRouterPrefetch(Vue, { componentName = 'RouterLink' } = {}) {
},
prefetchFiles: {
type: Array
},
timeout: {
type: Number,
default: 2000
}
},
mounted() {
if (this.prefetch && observer && canPrefetch) {
requestIdleCallback(this.observe, { timeout: 1000 })
requestIdleCallback(this.observe, { timeout: this.timeout })
}
},
beforeDestory() {
Expand Down

0 comments on commit 8ef6171

Please sign in to comment.