Inside server.js, what we want to do is call a method on socket. The socket method has a method called emit, which we'll use on both the client and the server to emit events:
io.on('connection', (socket) => { console.log('New user connected'); socket.emit('');});
The emit method is really similar to the listeners; although, instead of listening to an event, we are creating the event. The first argument is the same. It's going to be the name of the event you want to emit. In this case, we have to match it exactly as we specified in index.js, newEmail. Now, as shown in the following code, we'll provide newEmail:
io.on('connection', (socket) => { console.log('New user connected'); socket.emit('newEmail');});
Now, this is not ...