package arez.doc.examples.at_memoize2;

import arez.ComputableValue;
import arez.annotations.Action;
import arez.annotations.ArezComponent;
import arez.annotations.ComputableValueRef;
import arez.annotations.DepType;
import arez.annotations.Memoize;
import arez.annotations.OnActivate;
import arez.annotations.OnDeactivate;
import akasha.Global;
import akasha.EventListener;

@ArezComponent
public abstract class NetworkStatus
{
  private final EventListener _listener = e -> updateOnlineStatus();

  // Specify depType so can explicitly trigger a recalculation
  // of method using reportPossiblyChanged()
  @Memoize( depType = DepType.AREZ_OR_EXTERNAL )
  public boolean isOnLine()
  {
    return Global.navigator().onLine();
  }

  @ComputableValueRef
  abstract ComputableValue<Boolean> getOnLineComputableValue();

  @OnActivate
  void onOnLineActivate()
  {
    DomGlobal.window.addEventListener( "online", _listener );
    DomGlobal.window.addEventListener( "offline", _listener );
  }

  @OnDeactivate
  void onOnLineDeactivate()
  {
    DomGlobal.window.removeEventListener( "online", _listener );
    DomGlobal.window.removeEventListener( "offline", _listener );
  }

  @Action
  void updateOnlineStatus()
  {
    // Explicitly trigger a recalculation of the OnLine value
    getOnLineComputableValue().reportPossiblyChanged();
  }
}

@@ -33,16 +33,67 @@
 oize2;%0A%0A
+import akasha.EventListener;%0Aimport akasha.Global;%0A
 import a
@@ -371,59 +371,8 @@
 ate;
-%0Aimport akasha.Global;%0Aimport akasha.EventListener;
 %0A%0A@A
@@ -865,52 +865,33 @@
     
-Dom
 Global.
-window.addEventListener( %22online%22,
+addOnlineListener(
  _li
@@ -908,53 +908,34 @@
     
-Dom
 Global.
-window.addEventListener( %22offline%22,
+addOfflineListener(
  _li
@@ -1005,55 +1005,36 @@
     
-Dom
 Global.
-window.removeEventListener( %22online%22,
+removeOnlineListener(
  _li
@@ -1051,56 +1051,37 @@
     
-Dom
 Global.
-window.removeEventListener( %22offline%22,
+removeOfflineListener(
  _li

Remove Elemental2 usage from doc example