Returnable async promises
See original GitHub issueVue.components allow promise (resolve, reject), but they don’t allow returnable promises. I want to be able to return a promise for async components.
I want to do this:
Vue.component('async-component', function () {
return new Promise(function (resolve, reject) {
//step 1
}).then(function () {
//step 2
}).then(function () {
return {
template: '<p>hi</p>'
}
})
})
new Vue({
el: '#demo'
})
rather than this:
Vue.component('async-component', function (resolve, reject) {
new Promise(function (resolve, reject) {
//step 1
}).then(function () {
//step 2
}).then(function () {
resolve({
template: '<p>hi</p>'
})
}).catch(function (error) {
reject(error)
})
})
new Vue({
el: '#demo'
})
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:12 (10 by maintainers)
Top Results From Across the Web
How to use promises - Learn web development | MDN
A promise is an object returned by an asynchronous function, which represents the current state of the operation. At the time the promise...
Read more >async/await implicitly returns promise? - Stack Overflow
Yes, an async function will always return a promise. According to the tc39 spec, an async function ...
Read more >'return await promise' vs 'return promise' in JavaScript
Is there any difference between using 'return await promise' and 'return promise' in asynchronous JavaScript functions?
Read more >Async and Await in JavaScript, the extension to a promise.
An async function simply implies that a promise will be returned and if a promise is not returned, JavaScript will automatically wrap it...
Read more >Returning Promises From Async / Await Functions In JavaScript
The return value of an async function is implicitly wrapped in Promise.resolve - if it's not already a promise itself (as in this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, thx and sorry again for bothering. @posva
@JounQin Well that’s another subject I’m sure you’ll find information by searching on Google or the forums