Created
February 3, 2010 08:49
-
-
Save tlrobinson/293483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EXAMPLE 1 | |
// PSGI equivalent | |
var app = function(env) { | |
return function(respond) { | |
// do some event stuff | |
setTimeout(function() { | |
respond({ status : code, headers : headers, body : body }); | |
}, 1000); | |
} | |
} | |
// AJSGI | |
var app = function(env) { | |
return { then : function(respond) { | |
// do some event stuff | |
setTimeout(function() { | |
respond({ status : code, headers : headers, body : body }); | |
}, 1000); | |
}}; | |
} | |
// EXAMPLE 2 | |
// PSGI equivalent | |
var app = function(env) { | |
return function(respond) { | |
var w = respond({ status : code, headers : headers }); | |
// do more event stuff | |
setTimeout(function() { w.write(body); }, 1000); | |
setTimeout(function() { w.close(); }, 2000); | |
} | |
} | |
// AJSGI | |
var app = function(env) { | |
return { then : function(respond) { | |
// do some event stuff | |
respond({ status : code, headers : headers, body : { forEach : function(write) { | |
return { then : function(close) { | |
setTimeout(function() { write(body); }, 1000); | |
setTimeout(function() { close(); }, 2000); | |
}}; | |
}}); | |
}}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment