title: Request handling with React, Redux and Websocket
body: <p>I’m developing an application in which I use ReactJS, Redux and Websockets. In this application I’m implementing live rendering feature. (User will get notification on the screen without refreshing the page). </p>
  
  <p>Let’s say I have 2 components which I need to render. </p>
  
  <ul>
  <li>Notification</li>
  <li>Chat</li>
  </ul>
  
  <p>I was thinking of opening 2 separate sockets with accessing 2 separate end points to get data for these 2 components. </p>
  
  <p>Notification Component</p>
  
  <pre><code>componentDidMount() {
      io("sample.data/endpoint/notification").on("data", data =&gt; this.setState({notificationData: data}));
  }
  </code></pre>
  
  <p>Chat Component</p>
  
  <pre><code>componentDidMount() {
      io("sample.data/endpoint/chat").on("data", data =&gt; this.setState({chatData: data}));
  }
  </code></pre>
  
  <p>Instead of using 2 separate sockets, is there a way which i can do both these functions using 1 socket? In other words, there is an endpoint which retrieves both Notification and Chat data and and after getting that data, is there a way for me to filter and then feed those separate data in to 2 components?</p>
  
  <blockquote>
    <p>In other words, is there a way to keep a centralized class to handle
    all the Websocket requests and feed the response to different
    components?</p>
  </blockquote>
  
  <p>Let me know your comments regarding this and suggest me a way to approach this.</p>