Skip to main content
Version: 1.x

Interface: IExtensionService

molecule.IExtensionService

Implemented by

Methods

activate

activate(extensions): void

Activate the extensions (includes contributes type). Notice: this method only do the activate work, not store the data into ExtensionService, which means you can't get the Extension by the ExtensionService. getExtension method.

Parameters

NameType
extensionsIExtension[]

Returns

void

Defined in

services/extensionService.ts:40


add

add(extensions): null | IExtension[]

Add the extensions to ExtensionService, but no activated.

Parameters

NameTypeDescription
extensionsIExtension[]The Extensions wait to added

Returns

null | IExtension[]

Unload Extensions

Defined in

services/extensionService.ts:33


dispose

dispose(extensionId): void

Dispose the specific extension, and remove it from the ExtensionService

Parameters

NameType
extensionIdUniqueId

Returns

void

Defined in

services/extensionService.ts:55


disposeAll

disposeAll(): void

Dispose all extensions, and reset the ExtensionService

Returns

void

Defined in

services/extensionService.ts:59


executeCommand

executeCommand(id, ...args): void

Execute the registered command

Parameters

NameTypeDescription
idstringThe command ID
...argsany

Returns

void

Defined in

services/extensionService.ts:92


getAllExtensions

getAllExtensions(): IExtension[]

Get All loaded extensions

Returns

IExtension[]

Extension Array

Defined in

services/extensionService.ts:50


getExtension

getExtension(id): undefined | IExtension

Get an extension by the ID

Parameters

NameType
idUniqueId

Returns

undefined | IExtension

Defined in

services/extensionService.ts:45


inactive

inactive(predicate): void

Disable to activate some extensions, make use of it to filter some extensions no need to activate. You need register the inactive event before the MoleculeProvider declaration.

example

molecule.extension.inactive((extension: IExtension) => {
if (/^(idA|idB)$/.test(extension.id)) {
return true;
}
});
<MoleculeProvider extensions={[]}></MoleculeProvider>;

Parameters

NameTypeDescription
predicate(extension: IExtension) => booleanThe predicate function

Returns

void

Defined in

services/extensionService.ts:74


isLoaded

isLoaded(): boolean

whether the extensions are loaded

Returns

boolean

Defined in

services/extensionService.ts:106


load

load(extensions): void

Load the extension instances and then activate them. Notice: The ExtensionService doesn't load an existed Extension, if you want inactivate someone extension, there can use the ExtensionService.inactive method, also if you want remove a extension, you can use the ExtensionService.dispose method.

Parameters

NameTypeDescription
extensionsIExtension[]The extension array

Returns

void

Defined in

services/extensionService.ts:27


registerAction

registerAction(actionClass): IDisposable

Register a new action which is extends the Action2, and return a disposable instance.

example

const action = class Action extends Action2 {};
const disposableAction = registerAction(action);
disposableAction.dispose(); // Dispose the action

Parameters

NameTypeDescription
actionClass() => Action2The action class

Returns

IDisposable

IDisposable The Disposable instance

Defined in

services/extensionService.ts:86


reset

reset(): void

Reset the extensions to []

Returns

void

Defined in

services/extensionService.ts:96


setLoaded

setLoaded(flag?): void

Set the extensions are loaded

Parameters

NameType
flag?boolean

Returns

void

Defined in

services/extensionService.ts:110


splitLanguagesExts

splitLanguagesExts(extensions): [IExtension[], IExtension[]]

Distinguish the language extensions from extensions

Parameters

NameType
extensionsIExtension[]

Returns

[IExtension[], IExtension[]]

Defined in

services/extensionService.ts:102