APIs
Overview
Available since @interopio/manager-api 4.2.0
The @interopio/manager-api library provides a ManagerLib export that can be included as an additional library when initializing the @interopio/desktop library in io.Connect Desktop projects and the @interopio/browser-platform and @interopio/browser libraries in io.Connect Browser projects.
This enables interacting with io.Manager from interop-enabled apps running in io.Connect Desktop and io.Connect Browser - retrieving the connection state, subscribing for connection state changes, and refreshing platform data such as available apps, Layouts, system configurations, and more.
The following sections describe how to use the ManagerLib export in io.Connect Desktop and io.Connect Browser projects and provide a comprehensive API reference.
ℹ️ For details on configuring your io.Connect Desktop and io.Connect Browser platforms to connect to the io.Manager Server, see the Configuration > Platform section.
io.Connect Desktop
Available since io.Connect Desktop 10.3
To use the functionalities provided by the ManagerLib export in io.Connect Desktop client apps, you must include it in the libraries array of the configuration object for initializing the @interopio/desktop library.
When the io.Connect library has been initialized, a new manager property will be added to the io.Connect API object and the available methods will become accessible via the io.manager object:
import IODesktop from "@interopio/desktop";
import { ManagerLib } from "@interopio/manager-api/desktop";
// Including the `ManagerLib` export as an additional library.
const config = { libraries: [ManagerLib] };
const io = await IODesktop(config);
// Retrieving the state of the connection to io.Manager.
const connectionState = await io.manager.getConnectionState();
// Providing a handler and subscribing for changes in the connection state.
const handler = connectionState => console.log(`Connection state: ${JSON.stringify(connectionState)}`);
const unsubscribe = io.manager.onConnectionStateChange(handler);
// Refreshing the available apps and Layouts.
const dataToFetch = {
layouts: true,
applications: true
};
await io.manager.fetchData(dataToFetch);ℹ️ For more details on the available methods, see the API Reference section.
io.Connect Browser
Available since io.Connect Browser 4.3
Main App
To use the functionalities provided by the ManagerLib export in the Main app of your io.Connect Browser project, you must include it in the libraries array of the browser object inside the configuration object for initializing the @interopio/browser-platform library.
When the io.Connect library has been initialized, a new manager property will be added to the io.Connect API object and the available methods will become accessible via the io.manager object:
import IOBrowserPlatform from "@interopio/browser-platform";
import { ManagerLib } from "@interopio/manager-api/browser";
const config = {
licenseKey: "my-license-key",
browser: {
// Including the `ManagerLib` export as an additional library.
libraries: [ManagerLib]
},
manager: {
// Settings for connecting to io.Manager.
}
};
const { io } = await IOBrowserPlatform(config);
// Retrieving the state of the connection to io.Manager.
const connectionState = await io.manager.getConnectionState();
// Providing a handler and subscribing for changes in the connection state.
const handler = connectionState => console.log(`Connection state: ${JSON.stringify(connectionState)}`);
const unsubscribe = io.manager.onConnectionStateChange(handler);
// Refreshing the available apps and Layouts.
const dataToFetch = {
layouts: true,
applications: true
};
await io.manager.fetchData(dataToFetch);ℹ️ For more details on the available methods, see the API Reference section.
Browser Clients
To use the functionalities provided by the ManagerLib export in Browser Client apps running in io.Connect Browser, you must include it in the libraries array of the configuration object for initializing the @interopio/browser library.
When the io.Connect library has been initialized, a new manager property will be added to the io.Connect API object and the available methods will become accessible via the io.manager object:
import IOBrowser from "@interopio/browser";
import { ManagerLib } from "@interopio/manager-api/browser";
// Including the `ManagerLib` export as an additional library.
const config = { libraries: [ManagerLib] };
const io = await IOBrowser(config);
// Retrieving the state of the connection to io.Manager.
const connectionState = await io.manager.getConnectionState();
// Providing a handler and subscribing for changes in the connection state.
const handler = connectionState => console.log(`Connection state: ${JSON.stringify(connectionState)}`);
const unsubscribe = io.manager.onConnectionStateChange(handler);
// Refreshing the available apps and Layouts.
const dataToFetch = {
layouts: true,
applications: true
};
await io.manager.fetchData(dataToFetch);ℹ️ For more details on the available methods, see the API Reference section.
API Reference
The following sections describe the methods and types exposed by the ManagerLibAPI interface, accessible via io.manager object after the ManagerLib library has been included as an additional library when initializing the respective libraries in your io.Connect Desktop or io.Connect Browser projects.
Methods
The following methods are available via the io.manager object.
fetchData()
Triggers data refresh from io.Manager. You can specify the types of data to be refreshed (e.g. data related to the available apps, Layouts, system configurations).
Signature:
fetchData(args: FetchDataArgs): Promise<void>;Parameters:
| Parameter | Type | Description |
|---|---|---|
args |
object |
FetchDataArgs object where each key corresponds to a type of data that can be refreshed. |
Returns: Promise that resolves with void.
getConnectionState()
Retrieves information related to the state of the connection to io.Manager.
Signature:
getConnectionState(): Promise<IOManagerConnectionState>;Returns: Promise that resolves with an IOManagerConnectionState object.
onConnectionStateChange()
Notifies when the state of the connection to io.Manager changes.
Signature:
onConnectionStateChange(
callback: (connectionState: IOManagerConnectionState) => void
): UnsubscribeFunction;Parameters:
| Parameter | Type | Description |
|---|---|---|
callback |
function |
Callback function for handling the event. Accepts as an argument an IOManagerConnectionState object describing the new connection state. |
Returns: UnsubscribeFunction that can be used to stop tracking the event.
Types
FetchDataArgs
Describes the data categories to be refreshed. Passed as an argument to the fetchData() method.
| Property | Type | Description |
|---|---|---|
applications |
boolean |
If true, app data will be refreshed. |
commands |
boolean |
If true, command data will be refreshed. |
configs |
boolean |
If true, system configuration data will be refreshed. |
layouts |
boolean |
If true, Layout data will be refreshed. |
IOManagerConnectionState
Describes the current connection state of the io.Manager client.
| Property | Type | Description |
|---|---|---|
baseUrl |
string |
The base URL of the io.Manager Server. |
cacheEnabled |
boolean |
If true, client-side caching is enabled. |
disconnectionError |
Error |
The error that caused the disconnection if the client has been disconnected due to an error. |
isConnected |
boolean |
If true, the client is currently connected to the io.Manager Server. |
serverEnabled |
boolean |
If true, the io.Manager Server is enabled in the io.Connect platform. |