title: How to deregister a function from SignalR client?
body: <p>Consider the following code:</p>
  
  <pre><code>var connection = new signalR.HubConnectionBuilder().withUrl("/hub").build();
  
  connection.on("ReceiveMessage", (message) =&gt; {
      console.log("Once");
  });
  
  connection.on("ReceiveMessage", (message) =&gt; {
      console.log("Twice");
  });
  </code></pre>
  
  <p>Now when the server sends <code>ReceiveMessage</code> to the client, the browser's console contains... both <code>Once</code> and <code>Twice</code>. Apparently, both functions are invoked.</p>
  
  <p>Problem is, in of my inexperience &amp; lack of knowledge I assumed that registering a new function for the same command (<code>ReceiveMessage</code> in this case) will automatically repleace the previously registered function, if there was any. And I was writing my program with that assumption. I only had to verify this assumption once I started noticing bizzarre behavior of my program.</p>
  
  <p>Can I somehow deregister previously registered handlers? Or should I rewrite my JS code with the assumption that I should only register one function per connection per command?</p>