Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Latest commit

 

History

History
69 lines (51 loc) · 2.52 KB

README.md

File metadata and controls

69 lines (51 loc) · 2.52 KB

Deprecated

Project has been merged into arez-dom


Arez-NetworkStatus

Build Status

This library provides an Arez browser component that tracks when the user is "online". The online state is essentially a reflection of the browsers "navigator.onLine" value. If an observer is observing the model, the model listens for changes from the browser and updates the online state as appropriate. However if there is no observer for the state, the model will not listen to to the browser events so as not to have any significant performance impact.

Quick Start

The simplest way to use component;

  • add the following dependencies into the build system. i.e.
<dependency>
   <groupId>org.realityforge.arez.networkstatus</groupId>
   <artifactId>arez-networkstatus</artifactId>
   <version>0.57</version>
</dependency>
  • add the snippet <inherits name="arez.networkstatus.NetworkStatus"/> into the .gwt.xml file.

  • Use the NetworkStatus component. eg.

import arez.Arez;
import arez.networkstatus.NetworkStatus;
import com.google.gwt.core.client.EntryPoint;
import elemental2.dom.DomGlobal;

public class NetworkStatusExample
  implements EntryPoint
{
  @Override
  public void onModuleLoad()
  {
    final NetworkStatus networkStatus = NetworkStatus.create();
    Arez.context().observe( () ->
                              DomGlobal.document.querySelector( "#network" ).textContent =
                                "Network Status: " + ( networkStatus.isOnLine() ? "Online" : "Offline" ) );
  }
}

More Information

For more information about component, please see the Website. For the source code and project support please visit the GitHub project.

Contributing

The component was released as open source so others could benefit from the project. We are thankful for any contributions from the community. A Code of Conduct has been put in place and a Contributing document is under development.

License

The component is licensed under Apache License, Version 2.0.