Project has been merged into arez-dom
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.
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" ) );
}
}
For more information about component, please see the Website. For the source code and project support please visit the GitHub project.
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.
The component is licensed under Apache License, Version 2.0.