-
-
Save mAAdhaTTah/ab7dbca408e58146a7ca 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
var http = require('http'); | |
var _ = require('lodash'); | |
// An HTTP server for an quick EventEmitter example. Works just like a socket. | |
var server = http.createServer(function(req, res) { | |
console.log('Reqest incoming...'); | |
}); | |
// This will not cause an error since partial is invoked after socket gets passed into the function. | |
server.on('connection', function(socket) { | |
setTimeout(_.partial(handleConnection, socket), 100); | |
}); | |
function handleConnection(socket, time) { | |
console.log(socket, time); | |
} | |
server.listen(8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment