mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
Simplify fix and cover other Promise checks
This commit is contained in:
parent
93c4be2d28
commit
c22b0b790b
@ -166,7 +166,7 @@ function render (to, from, next) {
|
|||||||
}
|
}
|
||||||
if (Component.options.fetch) {
|
if (Component.options.fetch) {
|
||||||
var p = Component.options.fetch(context)
|
var p = Component.options.fetch(context)
|
||||||
if (!(p instanceof Promise)) { p = Promise.resolve(p) }
|
if (!p || (!(p instanceof Promise) && (typeof p.then !== 'function'))) { p = Promise.resolve(p) }
|
||||||
<%= (loading ? 'p.then(() => this.$loading.increase && this.$loading.increase(30))' : '') %>
|
<%= (loading ? 'p.then(() => this.$loading.increase && this.$loading.increase(30))' : '') %>
|
||||||
promises.push(p)
|
promises.push(p)
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ function addHotReload ($component, depth) {
|
|||||||
// Call fetch()
|
// Call fetch()
|
||||||
Component.options.fetch = Component.options.fetch || noopFetch
|
Component.options.fetch = Component.options.fetch || noopFetch
|
||||||
let pFetch = Component.options.fetch(context)
|
let pFetch = Component.options.fetch(context)
|
||||||
if (!(pFetch instanceof Promise)) { pFetch = Promise.resolve(pFetch) }
|
if (!pFetch || (!(pFetch instanceof Promise) && (typeof pFetch.then !== 'function'))) { pFetch = Promise.resolve(pFetch) }
|
||||||
<%= (loading ? 'pFetch.then(() => this.$loading.increase && this.$loading.increase(30))' : '') %>
|
<%= (loading ? 'pFetch.then(() => this.$loading.increase && this.$loading.increase(30))' : '') %>
|
||||||
promises.push(pFetch)
|
promises.push(pFetch)
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
|
@ -81,7 +81,7 @@ export default context => {
|
|||||||
// nuxtServerInit
|
// nuxtServerInit
|
||||||
<% if (store) { %>
|
<% if (store) { %>
|
||||||
let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context), 'redirect', 'error')) : null)
|
let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context), 'redirect', 'error')) : null)
|
||||||
if (!promise || (!(promise instanceof Promise) && (promise && typeof promise.then !== 'function'))) promise = Promise.resolve()
|
if (!promise || (!(promise instanceof Promise) && (typeof promise.then !== 'function'))) promise = Promise.resolve()
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
let promise = Promise.resolve()
|
let promise = Promise.resolve()
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -84,7 +84,7 @@ export function promisify (fn, context) {
|
|||||||
} else {
|
} else {
|
||||||
promise = fn(context)
|
promise = fn(context)
|
||||||
}
|
}
|
||||||
if (!(promise instanceof Promise)) {
|
if (!promise || (!(promise instanceof Promise) && (typeof promise.then !== 'function')))
|
||||||
promise = Promise.resolve(promise)
|
promise = Promise.resolve(promise)
|
||||||
}
|
}
|
||||||
return promise
|
return promise
|
||||||
|
@ -52,7 +52,7 @@ export function promisifyRoute (fn) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
let promise = fn()
|
let promise = fn()
|
||||||
if (!(promise instanceof Promise)) {
|
if (!promise || (!(promise instanceof Promise) && (typeof promise.then !== 'function')))
|
||||||
promise = Promise.resolve(promise)
|
promise = Promise.resolve(promise)
|
||||||
}
|
}
|
||||||
return promise
|
return promise
|
||||||
|
Loading…
Reference in New Issue
Block a user