Created
January 20, 2013 20:11
-
-
Save vicapow/4581353 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 sockets = [...] ; // some array of sockets | |
for(var i = 0; i < sockets.length; i++){ | |
socket.on( 'CardPick', function(data) { | |
Draft.cardPick( data, draftId, socket ); | |
// `socket` will always be the last item in `sockets` every time the callback is called on any of the sockets | |
}); | |
} | |
for(var i = 0; i < sockets.length; i++){ | |
(function(socket){ | |
socket.on( 'CardPick', function(data) { | |
Draft.cardPick( data, draftId, socket ); | |
// `socket` will now be what we expect it to be. | |
}); | |
})(socket); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment