Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit edc3257

Browse files
author
Guillaume Chau
committed
feat: merge ssrPrefetch
1 parent 27b4799 commit edc3257

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

‎src/server/render.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ const normalizeRender = vm => {
5050
}
5151

5252
function waitForSsrPrefetch (vm, resolve, reject) {
53-
if (isDef(vm.$options.ssrPrefetch)) {
53+
const handlers = vm.$options.ssrPrefetch
54+
if (isDef(handlers)) {
5455
try {
55-
const result = vm.$options.ssrPrefetch.call(vm, vm)
56-
if (result && typeof result.then === 'function') {
57-
result.then(resolve).catch(reject)
58-
return
56+
const promises = []
57+
for (let i = 0, j = handlers.length; i < j; i++) {
58+
const result = handlers[i].call(vm, vm)
59+
if (result && typeof result.then === 'function') {
60+
promises.push(result)
61+
}
5962
}
63+
Promise.all(promises).then(resolve).catch(reject)
64+
return
6065
} catch (e) {
6166
reject(e)
6267
}

‎src/shared/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ export const LIFECYCLE_HOOKS = [
1717
'destroyed',
1818
'activated',
1919
'deactivated',
20-
'errorCaptured'
20+
'errorCaptured',
21+
'ssrPrefetch'
2122
]

0 commit comments

Comments
 (0)