Last active
November 3, 2018 16:41
-
-
Save UsamaAshraf/b203c9348ed565fe3ac927c2a095e4e9 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
class ChatUser { | |
displayNewMessageNotification(newMessage) { | |
// Push an alert message or something. | |
} | |
// `chatroom` is an instance of EventEmitter. | |
connectToChatroom(chatroom) { | |
chatroom.on('message-received', this.displayNewMessageNotification); | |
} | |
disconnectFromChatroom(chatroom) { | |
chatroom.removeListener('message-received', this.displayNewMessageNotification); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment