Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Promise Demonstration
- const asyncProblemSolver = isResolved => {
- return new Promise((resolve, reject) => {
- if (isResolved) {
- resolve("Problem is resolved!")
- } else {
- reject("Problem could not be resolved, sorry!")
- }
- })
- }
- console.log("Some syncronous task 01.")
- asyncProblemSolver(false).then(success => {
- return new Promise(resolve => {
- resolve(success + " Just double checked the solution.")
- })
- }).then(success => {
- console.log(success)
- }).catch(error => {
- console.log(error)
- })
- console.log("Some syncronous task 02.")
- setTimeout(() => {
- console.log("Some syncronous task 03.")
- console.log("Some syncronous task 04.")
- }, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement