title: Implementing "Someone is typing..." functionality in chat application using firebase cloud pub/sub
body: <p>I have ported the web version of the <a href="https://github.com/firebase/friendlychat" rel="nofollow noreferrer">friendlychat</a> example into the angular 4 suite. You can see mine live <a href="http://www.somombo.com" rel="nofollow noreferrer">over here</a> and it appears to be working okay... I shall publish it opensource shortly.</p>
  
  <p>Now I want to implement a feature that is such that when a User A starts typing then in realtime, user B should see a "User A is typing...." message. And when User A stops typing the message should disappear. Obviously, User A shouldn't see the message if he himself is typing.</p>
  
  <p>I am considering just having an object in the db like so:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
    "isTyping":true,
    "fromDeviceToken": "xxxx"
  }
  </code></pre>
  
  <p>... and then just altering the <code>isTyping</code> field using firebase realtime.</p>
  
  <p>Any better ideas about how can I achieve this? Any comments/improvements?</p>
  
  <p>My Main question is,</p>
  
  <p><strong>Can a Firebase Cloud <a href="https://firebase.google.com/docs/functions/pubsub-events" rel="nofollow noreferrer">pub/sub trigger</a> be used to do this without persisting the typing state in the db .. If so, how?</strong></p>