package org.realityforge.replicant.client.runtime.gwt;

import arez.annotations.ArezComponent;
import com.google.gwt.user.client.Timer;
import javax.annotation.Nonnull;
import javax.inject.Singleton;
import org.realityforge.replicant.client.aoi.AreaOfInterestService;
import org.realityforge.replicant.client.converger.ContextConverger;
import org.realityforge.replicant.client.runtime.ReplicantClientSystem;
import org.realityforge.replicant.client.subscription.EntitySubscriptionManager;

@Singleton
@ArezComponent
public abstract class GwtContextConverger
  extends ContextConverger
{
  private Timer _timer;

  GwtContextConverger( @Nonnull final EntitySubscriptionManager subscriptionManager,
                       @Nonnull final AreaOfInterestService areaOfInterestService,
                       @Nonnull final ReplicantClientSystem replicantClientSystem )
  {
    super( subscriptionManager, areaOfInterestService, replicantClientSystem );
  }

  @Override
  public boolean isActive()
  {
    return null != _timer;
  }

  @Override
  public void activate()
  {
    deactivate();
    _timer = new Timer()
    {
      @Override
      public void run()
      {
        converge();
      }
    };
    _timer.scheduleRepeating( CONVERGE_DELAY_IN_MS );
  }

  @Override
  public void deactivate()
  {
    cancelTimer();
    unpause();
  }

  @Override
  protected void release()
  {
    cancelTimer();
    super.release();
  }

  private void cancelTimer()
  {
    if ( null != _timer )
    {
      _timer.cancel();
      _timer = null;
    }
  }
}

@@ -456,22 +456,16 @@
 ription.
-Entity
 Subscrip
@@ -468,23 +468,23 @@
 cription
-Manager
+Service
 ;%0A%0A@Sing
@@ -642,14 +642,8 @@
 nal 
-Entity
 Subs
@@ -650,23 +650,23 @@
 cription
-Manager
+Service
  subscri
@@ -670,23 +670,23 @@
 cription
-Manager
+Service
 ,%0A      
@@ -877,15 +877,15 @@
 tion
-Manager
+Service
 , ar

Fix types