Tutorial: application.addEventListener

application.addEventListener

Registers an event listener on the specified event. Supported application event types are:

  • closed
  • connected
  • crashed
  • error
  • not-responding
  • out-of-memory
  • responding
  • started
  • run-requested
  • window-navigation-rejected
  • window-created
  • window-closed

Example

app.addEventListener("closed", function (event) {
    console.log("The application has closed");
}, function () {
    console.log("The registration was successful");
},function (reason) {
    console.log("failure: " + reason);
});

Application Events

closed

Generated when an application is closed.

//This response has the following shape:
{
    topic: "application",
    type: "closed",
    uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

connected

Generated when an application has authenticated and is connected.

//This response has the following shape:
{
    topic: "application",
    type: "connected",
    uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

crashed

Generated when an application crashes.

//This response has the following shape:
{
  topic: "application",
  type: "crashed",
  uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

error

Generated when an application error occurs.

//This response has the following shape:
{
  topic: "application",
  type: "error",
  uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

not-responding

Generated when an application is not responding.

//This response has the following shape:
{
  topic: "application",
  type: "not-responding",
  uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

out-of-memory

Generated when an application is out of memory.

//This response has the following shape:
{
  topic: "application",
  type: "out-of-memory",
  uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

responding

Generated when an application is responding.

//This response has the following shape:
{
  topic: "application",
  type: "responding",
  uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

started

Generated when an application has started.

//This response has the following shape:
{
  topic: "application",
  type: "started",
  uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

run-requested

Generated when Application.run() is called for an already running application.

//This response has the following shape:
{
  topic: "application",
  type: "run-requested",
  uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

window-navigation-rejected

Generated when window navigation is rejected as per ContentNavigation whitelist/blacklist rules

{
    name: "windowName",
    sourceName: "source of navigation window name",
    topic: "window-navigation-rejected",
    url: "http://blocked-content.url",
    uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

window-created

Generated when a child window is created for this Application

 {
    name: "windowName",
    topic: "application",
    type: "window-created",
    uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}

window-closed

Generated when a child window is closed.

{
    name: "windowName",
    topic: "application",
    type: "window-closed",
    uuid: "454C7F31-A915-4EA2-83F2-CFA655453C52" // the UUID of the application
}