# NetworkMonitor Class

Defined in: `js/net/NetworkMonitor.js:12`
Module: StructureJS

A helper class to detect network changes.

## Index

Show: Inherited Protected Private Deprecated

### Properties

- _eventDispatcher static
- _initialized

### Methods

- NetworkMonitor constructor static
- _dispatchEvent static
- _onNetworkMonitorEvent static
- _start static
- addEventListener static
- connected static
- getStatus static
- removeEventListener static

## Properties

### `_eventDispatcher` EventDispatcher private static

Defined in `js/net/NetworkMonitor.js:132`

A reference to the EventDispatcher object.

### `_initialized` Boolean private

Defined in `js/net/NetworkMonitor.js:141`

A flag to determine if this class has already been initialized.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

## Constructor

### `NetworkMonitor` () static

Defined in `js/net/NetworkMonitor.js:12`

## Methods

### `_dispatchEvent`
(

- `event`

)
private static

Defined in `js/net/NetworkMonitor.js:121`

Dispatches an event within the NetworkMonitorEvent object.

#### Parameters:

- `event` NetworkMonitorEvent

  The Event object that is dispatched into the event flow. You can create custom events, the only requirement is all events must extend the NetworkMonitorEvent.

### `_onNetworkMonitorEvent`
(

- `event`

)
private static

Defined in `js/net/NetworkMonitor.js:108`

An event handler method when the native Window 'online' and 'offline' events are triggered.

#### Parameters:

- `event` Object

### `_start` () private static

Defined in `js/net/NetworkMonitor.js:91`

Adds the necessary event listeners to listen for the 'online' and 'offline' events.

### `addEventListener`
(

- `type`
- `callback`
- `scope`
- `[priority=0]`

)
public static

Defined in `js/net/NetworkMonitor.js:53`

Registers an event listener object with an NetworkMonitor object so that the listener receives notification of an event.

#### Parameters:

- `type` String

  The type of event.

- `callback` Function

  The listener function that processes the event. This function must accept an Event object as its only parameter and must return nothing, as this example shows.

- `scope` Any

  Binds the scope to a particular object (scope is basically what "this" refers to in your function). This can be very useful in JavaScript because scope isn't generally maintained.

- `[priority=0]` Int optional

  Influences the order in which the listeners are called. Listeners with lower priorities are called after ones with higher priorities.

#### Example:

     NetworkMonitor.addEventListener(NetworkMonitorEvent.STATUS, this._handlerMethod, this);
     _handlerMethod(event) {
         console.log(event.status, event.connected);
     }

### `connected` () Boolean public static

Defined in `js/net/NetworkMonitor.js:27`

Returns the online status of the browser. The property returns a boolean value, with true for being online and false for being offline.

#### Returns:

Boolean:

#### Example:

     NetworkMonitor.connected();

### `getStatus` () String public static

Defined in `js/net/NetworkMonitor.js:40`

Returns if the status type ('online' or 'offline') if computer or device is connected to the internet.

#### Returns:

String:

Returns 'online' or 'offline'.

#### Example:

     NetworkMonitor.getStatus();

### `removeEventListener`
(

- `type`
- `callback`
- `scope`

)
public static

Defined in `js/net/NetworkMonitor.js:73`

Removes a specified listener from the NetworkMonitor object.

#### Parameters:

- `type` String

  The type of event.

- `callback` Function

  The listener object to remove.

- `scope` Any

  The scope of the listener object to be removed. To keep things consistent this parameter is required.

#### Example:

     NetworkMonitor.removeEventListener(NetworkMonitorEvent.STATUS, this._handlerMethod, this);
     _handlerMethod(event) {
         console.log(event.status, event.connected);
     }

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index