Lesson 32. Adding a Chat Notification Indicator

 

Your chat page is coming together. Now users can log in and view the most recent chat messages, whether they were sent moments or weeks ago. The chat page currently facilitates all the visual aspects of your application’s chat functionality. The nice thing about socket.io is that it doesn’t need to exist on one page. Because your chat works by emitting and handling events, you can use those events in other ways. In this lesson, you build a custom event emitter to notify all active users when chat messages are being submitted. Then you build a small visual indicator in the navigation bar that animates when new messages are being shared. Through this small feat, users get a visual indication of an active chat room even when they’re browsing a different page.

This lesson covers

  • Broadcasting a custom event
  • Animating an icon in response to an event
Consider this

Users are enjoying the chat page in your application, but they’d like to browse other pages in your application instead of waiting for new messages to arrive on the chat page. They don’t want to miss out when the chat is active again, however. In this lesson, you rely on a custom event emitted by the server to animate a navigation-bar icon. When this icon is animated, users on any page of the application know that a chat is active.

32.1. Broadcasting to all other sockets

32.2. Creating a chat indicator in navigation

Summary

sitemap