Skip to content

Commit

Permalink
Illustrate simple use of callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulcoder committed Sep 11, 2016
1 parent f5cd198 commit 9b5fad8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"version": "0.0.1",
"scripts": {
"test": "node_modules/.bin/mocha --ui bdd test/**/*.js",
"simple-callback": "node simpleCallback.js",
"callback-hell": "node callbackHell.js",
"dependency-inversion": "node callbackDependencyInversion.js",
"polymorphic-callback": "node callbackPolymorphic.js"
Expand Down
10 changes: 10 additions & 0 deletions simpleCallback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function receiver(fn) {
return fn();
}

function callback() {
return 'foobar';
}

var callbackResponse = receiver(callback);
console.log(callbackResponse);

0 comments on commit 9b5fad8

Please sign in to comment.