真实世界的 Promise async await 实践
2018-07-28 本文已影响1人
Apolo_Du

let {Life, RealWorldSkills} = RealWorld
let man = new Life('male')
let {makeFriendsWith} = RealWorldSkills
let {forget} = RealWorldSkills
function haveFunWith(girl){
dateWith(girl)
.then(makeHerShameful)
.then(takeHerKiss)
}
makeFriendsWith = makeFriendsWith.bind(man)
haveFunWith = haveFunWith.bind(man)
forget = forget.bind(man)
man.on('girlClosingIn', (girl)=>{
async function relationshipPromoted(){
return makeFriendsWith(girl)
}
await relationshipPromoted()
.then(haveFunWith)
.catch(forget)
})