Application API
An App instance can have the following methods.
Properties
publicScope
The methods provided by the Application public API will be accessible in menu icon handlers (onClick, onDrop etc.)
and actions plugged to this application.
Getters
getLayoutConfig
Mandatory
/**
* @returns {Object}
*/
getLayoutConfig() {
return {...};
}
layout
Layout is a JSON-serializable structure that is equal to the content
part of MCUX layouts.
- type
The simplest layout (which most of the apps will use) assumes that one view plugin
is used as the app’s UI:
{
'type': 'companyname-projectname-viewname'
}
Sample layout with a splitter:
{
'type': 'split',
'orientation': 'h',
'first': {
'type': 'av-customizable-logging'
},
'second': {
'type': 'av-logging'
}
}
Sample layout with tabs:
selectedIndex - index of the initially selected tab.
closable - boolean parameter that specifies when tabs should be rendered with close button (ability to close tabs).
{
‘type’: ‘tabs’,
‘closable’: true,
‘selectedIndex’: 0,
‘items’: [
{
‘type’: ‘av-mpd-social-message-form’
},
{
‘type’: ‘av-web-story-form’
},
{
‘type’: ‘av-combined-social-media-message-manager-form’
}
]
}
getContext
Optional
Returns the current application context.
Is used for building the deep link and history navigation in the browser.
/**
* Get current application context
*/
getContext() {
// return context;
}
See section Context for format details.
getTitle
Optional
Returns the application title.
Is used to be displayed in the application drop-down if the application is a multi-instance application.
If getTitle is not defined, the application name will be displayed.
/**
* Get application title
*/
getTitle() {
// return title;
}
Setters
setContext
Optional
Is used for setting the application context for the application.
/**
* Set application context
* @param {} context
*/
setContext(context) {
//
}
See section Context for format details.
Lifecycle
onInit
Optional
Is called immediately after application creation.
Parameters:
{Function } dispatch
Function to dispatch events to the Layout Manager
/**
* @param {Function} dispatch
*/
onInit({ dispatch }) {
this.dispatch = dispatch;
}
Events List:
appContextChange
To dispatch an event:
this.dispatch('appContextChange', {
"text/plain": "1v6a002",
"text/x.avid.asset-list": "interplay-pam:20AB378F-2BA3-4C34-912C-CB6ADEA3172E:masterclip:060a2b340101010101010f0013-000000-54171a7154f91090-060e2b347f7f-2a80",
"text/x.avid.location-item-list": "interplay-pam:20AB378F-2BA3-4C34-912C-CB6ADEA3172E:folder-item:/Projects/mike/060a2b340101010101010f0013-000000-54171a7154f91090-060e2b347f7f-2a80"
});
onRender
Optional
Is called after rendering dom with all views defined in the layout.
onRender(headerContentEl, views) {
// ...
}
Parameters:
{DomElement} headerContentEl DomElement where custom header content can be injected
{Object} views Inner views (object keys are equal to view type or label)
Views are created using the layout settings.
Each value contains only the view public scope.
views parameter example:
{
'avid-mcux-browse-view': browseViewPublicScope
'av-timeline': timelineViewPublicScope
}
onShow
Optional
Is called immediately after the application becomes visible.
onHide
Is called immediately after the application becomes invisible.
Stops permanent state updates in this hook.
State updates can be started again in the onShow hook, when the application becomes visible.
Optional
onClose
Optional
Is called before the application closes.
During this step, close can be rejected.
Can be used for asking the user to save his changes.
Returns:
{Promise} If Promise is rejected, app closing will be stopped.
onClose() {
return Promise.resolve();
}
onBeforeUnrender
Optional
Is called before dom destroying.
Performs any dom related cleanup in this method, such as removing listeners.
This hook can be used for saving the state for app instances that have the config option unrenderOnHide.
The app instances are staying alive after unrendering.
onDestroy
Optional
Is called when the application is destroyed (at this time dom is unrendered).
Performs necessary cleanup in this method, such as cancel requests, etc.
Events List
appContextChange
Event to request context opening in another app.
this.dispatch('appContextChange', {
"text/plain": "1v6a002",
"text/x.avid.asset-list": "interplay-pam:20AB378F-2BA3-4C34-912C-CB6ADEA3172E:masterclip:060a2b340101010101010f0013-000000-54171a7154f91090-060e2b347f7f-2a80",
});
See How to open the context in another app
in Context.
appStateChange
Event to report changes in the application state.
An application can report its inner context change:
this.dispatch('appStateChange', { context: {
"text/x.avid.location-item-list": "interplay-pam:20AB378F-2BA3-4C34-912C-CB6ADEA3172E:folder-item:/Projects/mike/060a2b340101010101010f0013-000000-54171a7154f91090-060e2b347f7f-2a80"
}
});
This context has impact on the browser history and deeplink building.