PROMISE : Angular promise dedication and example

yotube
0

 Promise handle async programming, Job quee is use to handle promise. 



promiseFunciton(val): Promise<any>{

return new Promise((resolve, reject)=>{
if(val ==1){
setTimeout(()=>{ resolve(1)}, 3000)
}else{
reject(2)
}
})
}
async asyncFunction(val){
let i = await this.promiseFunciton(val);
console.log("async",i)
}
----------------------
this.promiseFunciton(1)
.then((success)=>{
console.log("success")
}).catch((error)=>{
console.log("error")
});
this.asyncFunction(1);

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top