Application Management

JavaScript

Listing Applications

The Application Management API can be accessed through glue.appManager.

See our JavaScript Application Management example on GitHub.

You can see a list of all applications available to the current user:

glue.appManager.applications();

Starting Applications

To start an application use the start() method of the application object:

const app = glue.appManager.application("ClientList");
app.start();

You can also pass a context object (an application specific object that will be available in the newly opened app) or override any of the pre-configured window settings:

const app = glue.appManager.application("ClientList");
const applicationContext = { selectedUser: 2 };
const windowSettings = { hidden: true };

app.start(applicationContext, windowSettings);

Starting an application will return a new Promise for a new instance object:

app.start()
    .then((instance) => {
        // use instance
    });

Application Events

The set of applications defined for the current user can be changed at runtime. Applications can be added, removed or updated. To track these events, you can subscribe to:

  • an application added event:
// notifies you when an application is registered in the environment
glue.appManager.onAppAdded((application) => {
    console.log(application.name);
});
  • an application removed event:
// notifies you if the application is removed from the environment
glue.appManager.onAppRemoved((application) => {
    console.log(application.name);
});
  • an application updated event:
// notifies you when an application is available and can be started
glue.appManager.onAppChanged((application) => {
    console.log(application.name);
});

Listing Running Instances

To list all running instances, use the following:

glue.appManager.instances(); // returns an array of the running instances of your app

Stopping Instances

To stop a running instance, use the stop() method of an instance object:

instance.stop();

Instance Events

You can monitor instance related events globally (for all instances of all applications running in Glue42 Enterprise) or on an application level (only instances of a specific application).

Global

The AppManager object offers methods which you can use to monitor instance events for all applications running in Glue42 Enterprise. You can get notifications when an application instance is started, stopped, updated or when starting an application instance has failed. The methods for handling instance events receive a callback as a parameter which in turn receives the application instance as an argument. All methods return an unsubscribe function which you can use to stop receiving notifications about instance events.

  • application instance started:
glue.appManager.onInstanceStarted((instance) => {
    console.log(instance.id);
});
  • application instance stopped:
glue.appManager.onInstanceStopped((instance) => {
    console.log(instance.id);
});
  • application instance updated:
const unsubscribe = glue.appManager.onInstanceUpdated((instance) => {
    console.log(instance.id);
});

// stop getting notified whenever an application instance is updated
unsubscribe();

Application Level

You can also monitor instance events on an application level. Use the methods offered by the Application object to handle instance events. The methods for handling instance events receive a callback as a parameter which in turn receives the application instance as an argument.

  • instance started:
const app = glue.appManager.application("clientlist");

app.onInstanceStarted((instance) => {
    console.log(instance.id);
});
  • instance stopped:
const app = glue.appManager.application("clientlist");

app.onInstanceStopped((instance) => {
    console.log(instance.id);
});

Reference

Reference