cory.kelly
2/1/2017 - 11:55 AM

JavaScript Promises

JavaScript Promises



let promiseToCleanRoom = new Promise(function(resolve, reject){

    //Clean the room -> The promise work is done here..

    let isClean = true;
    if(isClean)
    {
        resolve('Clean');
    }
    else
    {
        reject('Trashed Bro!');
    }

});

promiseToCleanRoom.then(function(fromResolve){
    console.log('the room is ' + fromResolve );
}).catch(function(fromReject){
    console.log('the room is ' + fromReject );
})