Documentation

Runtime.loadExtension

Runtime.loadExtension(name: string|Array): Promise<{[key: string]: any} | Function | null>

Allows to execute deferred connection of extension to page. Can be useful, when features are displayed at the page not immediately, but, for example, in an opened pop-up, tab and etc.

The Runtime.loadExtension function returns a promise containing all exports for connected extension.

For example, if you connect the extension main.loader, the promise's value will contain the link to the object {Loader: Function}.

import {Runtime} from 'main.core';

Runtime.loadExtension('main.loader').then((exports) => {
	console.log(exports); // {Loader: Function}
	
	const {Loader} = exports;
	const loader = new Loader();
	
	loader.show();
});

When an extension is already connected to the page, the function Runtime.loadExtension returns a solved promise with the link to export's object (i. e. there won't be a repeat connection).



© «Bitrix24», 2001-2024
Up