March 2018
Intermediate to advanced
592 pages
13h 44m
English
Now, in order to listen to a custom event, we are still going to use socket.on; although, instead of specifying the name of one of the built-in events, we'll provide the first argument inside quotes as the name of our custom event. In this case, that name is going to be newEmail:
socket.on('newEmail');
Now, the second argument for socket.on is the same as the second argument for the built-in event listeners. We'll provide a function, and this function is going to get called when the event fires:
socket.on('newEmail', function () {});
For now, all we're going to do inside the function is use console.log to print a little message, New email:
socket.on('newEmail', function () { console.log('New email');});
This ...