package org.realityforge.arez.gwt.examples;

import elemental2.dom.DomGlobal;
import org.realityforge.arez.annotations.Action;
import org.realityforge.arez.annotations.Container;
import org.realityforge.arez.annotations.Observable;

@Container( singleton = true )
public class NetworkStatus
{
  private boolean _onLine;

  @Observable
  public boolean isOnLine()
  {
    return _onLine;
  }

  public void setOnLine( final boolean onLine )
  {
    _onLine = onLine;
  }

  @Action
  public void updateOnlineStatus()
  {
    setOnLine( DomGlobal.navigator.onLine );
  }
}

package org.realityforge.arez.gwt.examples;

import elemental2.dom.DomGlobal;
import org.realityforge.arez.annotations.Action;
import org.realityforge.arez.annotations.Computed;
import org.realityforge.arez.annotations.Container;
import org.realityforge.arez.annotations.Observable;

@Container( singleton = true )
public class NetworkStatus
{
  private boolean _rawOnLine;

  @Computed
  public boolean isOnLine()
  {
    return isRawOnLine();
  }

  @Observable
  boolean isRawOnLine()
  {
    return _rawOnLine;
  }

  void setRawOnLine( final boolean rawOnLine )
  {
    _rawOnLine = rawOnLine;
  }

  @Action
  public void updateOnlineStatus()
  {
    setRawOnLine( DomGlobal.navigator.onLine );
  }
}

Use computed value for OnLine flag