I am newbie to Node.js, actually I'm new to front end.
I am writing Node.js code to visualize data on the browser.
Below is the a piece of code:
var socket = io();
socket.on('data', function (data) {
newDataCallback(data);
});
socket.on('tweet', function (tweet) {
console.log('received tweet' + tweet);
newTweetCallback(tweet);
});
When I debug in Chrome, I found only the second socket.on was processing the data, but the first socket.on was skipped. I had a feeling that socket.on only only listen to one event at a time. Is it correct? How to listen and process on multiple event? Thank you for answering me this basic question.
Thank you!
via hpnhxxwn
No comments:
Post a Comment