Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.

Commit

Permalink
Added call stack example
Browse files Browse the repository at this point in the history
  • Loading branch information
mendezcode committed Jan 30, 2012
1 parent 9883c2b commit 610b8ed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/multi-callstack.js
@@ -0,0 +1,30 @@

/* Multi Call Stack */

var Multi = require('../');

var context = {
sum: function(a,b,cb) {
cb(null, a+b);
},
hello: function(name, cb) {
cb(null, 'Hello ' + name + '!');
}
}

var multi = new Multi(context, {flush: false});

multi.sum(1,2);
multi.sum(3,4);
multi.hello('Ernie');

// Run `exec` for the first time
multi.exec(function(err, results) {
console.log(err || results);
});

// Any upcoming `exec` calls will still
// make use of the original call stack
multi.exec(function(err, results) {
console.log(err || results);
});

0 comments on commit 610b8ed

Please sign in to comment.