Interface: IExtensionService
services.IExtensionService
Table of contents
Methods
- activate
- add
- dispose
- disposeAll
- executeCommand
- getAllExtensions
- getExtension
- inactive
- isLoaded
- load
- registerAction
- reset
- setLoaded
- splitLanguagesExts
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
Name | Type |
---|---|
extensions | IExtension [] |
Returns
void
Defined in
src/services/extensionService.ts:27
add
▸ add(extensions
): null
| IExtension
[]
Add the extensions to ExtensionService, but no activated.
Parameters
Name | Type | Description |
---|---|---|
extensions | IExtension [] | The Extensions wait to added |
Returns
null
| IExtension
[]
Unload Extensions
Defined in
src/services/extensionService.ts:20
dispose
▸ dispose(extensionId
): void
Dispose the specific extension, and remove it from the ExtensionService
Parameters
Name | Type |
---|---|
extensionId | UniqueId |
Returns
void
Defined in
src/services/extensionService.ts:42
disposeAll
▸ disposeAll(): void
Dispose all extensions, and reset the ExtensionService
Returns
void
Defined in
src/services/extensionService.ts:46
executeCommand
▸ executeCommand(id
, ...args
): void
Execute the registered command
Parameters
Name | Type | Description |
---|---|---|
id | string | The command ID |
...args | any |
Returns
void
Defined in
src/services/extensionService.ts:79
getAllExtensions
▸ getAllExtensions(): IExtension
[]
Get All loaded extensions
Returns
Extension Array
Defined in
src/services/extensionService.ts:37
getExtension
▸ getExtension(id
): undefined
| IExtension
Get an extension by the ID
Parameters
Name | Type |
---|---|
id | UniqueId |
Returns
undefined
| IExtension
Defined in
src/services/extensionService.ts:32
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.
Parameters
Name | Type | Description |
---|---|---|
predicate | (extension : IExtension ) => boolean | The predicate function |
Returns
void
Example
molecule.extension.inactive((extension: IExtension) => {
if (/^(idA|idB)$/.test(extension.id)) {
return true;
}
});
<MoleculeProvider extensions={[]}></MoleculeProvider>
Defined in
src/services/extensionService.ts:61
isLoaded
▸ isLoaded(): boolean
whether the extensions are loaded
Returns
boolean
Defined in
src/services/extensionService.ts:93
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
Name | Type | Description |
---|---|---|
extensions | IExtension [] | The extension array |
Returns
void
Defined in
src/services/extensionService.ts:14
registerAction
▸ registerAction(actionClass
): IDisposable
Register a new action which is extends the Action2, and return a disposable instance.
Parameters
Name | Type | Description |
---|---|---|
actionClass | () => Action2 | The action class |
Returns
IDisposable
IDisposable The Disposable instance
Example
const action = class Action extends Action2 {};
const disposableAction = registerAction(action);
disposableAction.dispose(); // Dispose the action
Defined in
src/services/extensionService.ts:73
reset
▸ reset(): void
Reset the extensions to []
Returns
void
Defined in
src/services/extensionService.ts:83
setLoaded
▸ setLoaded(flag?
): void
Set the extensions are loaded
Parameters
Name | Type |
---|---|
flag? | boolean |
Returns
void
Defined in
src/services/extensionService.ts:97
splitLanguagesExts
▸ splitLanguagesExts(extensions
): [IExtension
[], IExtension
[]]
Distinguish the language extensions from extensions
Parameters
Name | Type |
---|---|
extensions | IExtension [] |
Returns
[IExtension
[], IExtension
[]]
[ languagesExts, otherExtensions ]