Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add promise sample 🙌
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed Jun 20, 2016
1 parent a70cb7d commit 589997f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions promises/calculation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// We will transform this to promise
// setTimeout(function() {
// console.log(1 + 1);
// }, 1000)

var calculationPromise = new Promise(function(resolve, reject) {
setTimeout(function() {
console.log(1 + 1);
}, 1000)
});

function addTwo(value) {
return value + 2;
}

function printFinalValue(nextValue) {
console.log("The final value is ", nextValue);
}

calculationPromise
.then(addTwo)
.then(printFinalValue);

// Easy to read

0 comments on commit 589997f

Please sign in to comment.