Skip to content

Commit

Permalink
feat: add the promise task
Browse files Browse the repository at this point in the history
  • Loading branch information
eepson123tw committed Oct 31, 2024
1 parent 10f3d8a commit c1a3afe
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions utils/promise-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,41 @@ function runNewFetch(func: () => void) {
}

runNewFetch(main);



setTimeout(() => {

console.log("%Promise", consoleStyle, "Promise Task Start");


// This is a promise task that will be executed in the micro task queue

Promise.resolve().then(() => {
console.log(0)
return Promise.resolve(4) // it will be pushed to the micro task queue
// p4.then(res => fullfilled({})) // it will be pushed to the micro task queue
// if runtime has any Error, it wil be rejected
// otherwise it will be resolved or pending
// current it will be pending depends on the runtime
}).then(res => {
console.log(res)
})
Promise.resolve().then(() => {
console.log(1)
}).then(() => {
console.log(2)
}).then(() => {
console.log(3)
}).then(() => {
console.log(5)
}).then(() => {
console.log(6)
})

},10000)





0 comments on commit c1a3afe

Please sign in to comment.