title: Two way databinding to singleton service Blazor Serverside
body: <p>I have been playing with Blazor on the client using Webassembly quite a bit. But I thought I would try the serverside version now and I had a simple idea I wanted to try out.</p>
  
  <p>So my understading was that Blazor serverside uses SignalR to "push" out changes so that the client re-renders a part of its page.</p>
  
  <p>what I wanted to try was to databind to a property on a singleton service like this:</p>
  
  <pre><code>@page "/counter"
  @inject DataService dataService
  
  &lt;h1&gt;Counter&lt;/h1&gt;
  
  &lt;p&gt;Current count: @currentCount ok&lt;/p&gt;
  &lt;p&gt; @dataService.MyProperty  &lt;/p&gt;
  &lt;p&gt;
      @dataService.Id
  &lt;/p&gt;
  
  &lt;button class="btn btn-primary" @onclick="IncrementCount"&gt;Click me&lt;/button&gt;
  
  
  @code {
      int currentCount = 0;
  
      void IncrementCount()
      {
          currentCount++;
          dataService.MyProperty += "--o--|";
      }
  
  
  }
  </code></pre>
  
  <p>Startup.cs:</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddRazorPages();
          services.AddServerSideBlazor();
          services.AddSingleton&lt;WeatherForecastService&gt;();
          services.AddSingleton&lt;DataService&gt;();
      }
  </code></pre>
  
  <p>Service:</p>
  
  <pre><code>namespace bl1.Services
  {
  public class DataService
  {
      public DataService()
      {
          this.Id = System.Guid.NewGuid().ToString();
      }
      public string Id {get;set;}
      public string MyProperty { get; set; }  
  }
  }
  </code></pre>
  
  <p>So my question is this. Why, if I open up this page in two tabs, do I not immediately see the value being updated for the property <strong>MyProperty</strong> with SignalR when I am changing the value on the property in one tab in the other tab? Is there a reason that is not supposed to work or am I just simply doing it wrong?</p>
  
  <p>I thought the upside of using Blazor on the serverside was that you could easily use the fact that SignalR is available and get live updates when values change on the server. </p>
  
  <p>I do get the latest value from the singleton service in the other tab but only after I click the button there.</p>