-
-
Save vbguard/a1b9f7d5eb0bb10ec5d9b599d01d7cd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promisify = (func) => () => new Promise((resolve) => func(resolve)); | |
const showBackground = (resolve) => { | |
setTimeout(() => { | |
console.log('showBackground works!!!'); | |
resolve(); | |
} , 3000); | |
}; | |
const slideSidebar = (resolve) => { | |
setTimeout(() => { | |
console.log('slideSidebar works!!!'); | |
resolve(); | |
} , 3000); | |
}; | |
const showMenu = (resolve) => { | |
setTimeout(() => { | |
console.log('showMenu works!!!'); | |
resolve(); | |
} , 3000); | |
}; | |
const showCloseBtn = (resolve) => { | |
setTimeout(() => { | |
console.log('showCloseBtn works!!!'); | |
resolve(); | |
} , 3000); | |
}; | |
const showBackgroundAsync = promisify(showBackground); | |
const slideSidebarAsync = promisify(slideSidebar); | |
const showMenuAsync = promisify(showMenu); | |
const showCloseBtnAsync = promisify(showCloseBtn); | |
// (async() => { | |
// await showBackgroundAsync(); | |
// await slideSidebarAsync(); | |
// await showMenuAsync(); | |
// await showCloseBtnAsync(); | |
// | |
// })(); | |
// showBackgroundAsync() | |
// .then(slideSidebarAsync) | |
// .then(showMenuAsync) | |
// .then(showCloseBtnAsync); | |
(async() => { | |
const operations = [showBackgroundAsync, slideSidebarAsync, showMenuAsync, showCloseBtnAsync]; | |
for (let i = 0; i < operations.length; i++) { | |
const operation = operations[i]; | |
await operation(); | |
} | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment