StructureJS

0.15.2

A class based utility library for building modular and scalable web platform applications. Features opt-in classes and utilities which provide a solid foundation and toolset to build your next project.

NetworkMonitor Class

A helper class to detect network changes.

Index

Show:

Properties

Methods

Properties

_eventDispatcher EventDispatcher private static

A reference to the EventDispatcher object.

_initialized Boolean private

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

Methods

_dispatchEvent
(
  • event
)
private static

Dispatches an event within the NetworkMonitorEvent object.

Parameters:

_onNetworkMonitorEvent
(
  • event
)
private static

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

Parameters:

_start () private static

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

addEventListener
(
  • type
  • callback
  • scope
  • [priority=0]
)
public static

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

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

Returns:

Example:

 NetworkMonitor.connected();

getStatus () String public static

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

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