docs: ExtensionManager class docs

This commit is contained in:
dannyrb 2019-12-08 14:37:54 -05:00
parent 8edba24eec
commit ac69b0a656
2 changed files with 29 additions and 0 deletions

View File

@ -27,6 +27,7 @@
- [Toolbar](extensions/modules/toolbar.md) - [Toolbar](extensions/modules/toolbar.md)
- [Viewport](extensions/modules/viewport.md) - [Viewport](extensions/modules/viewport.md)
- [Contexts](extensions/index.md#contexts) - [Contexts](extensions/index.md#contexts)
- [ExtensionManager](extensions/index.md#extension-manager)
- [OHIF Maintained](extensions/index.md#maintained-extensions) - [OHIF Maintained](extensions/index.md#maintained-extensions)
- [Services](services/index.md) - [Services](services/index.md)
- [Default](services/default/index.md) - [Default](services/default/index.md)

View File

@ -8,6 +8,7 @@
- [Modules](#modules) - [Modules](#modules)
- [Contexts](#contexts) - [Contexts](#contexts)
- [Consuming Extensions](#consuming-extensions) - [Consuming Extensions](#consuming-extensions)
- [Extension Manager](#extension-manager)
- [Maintained Extensions](#maintained-extensions) - [Maintained Extensions](#maintained-extensions)
## Overview ## Overview
@ -188,6 +189,33 @@ with current theming, configuration, extension, and services support.
If you're not sure how to achieve your goals with the extensibility available If you're not sure how to achieve your goals with the extensibility available
today, create a GitHub issue! today, create a GitHub issue!
### `ExtensionManager`
The `ExtensionManager` is a class made available to us via the `@ohif/core`
project (platform/core). Our application instantiates a single instance of it,
and provides a `ServicesManager` and `CommandsManager`.
```js
const commandsManager = new CommandsManager();
const servicesManager = new ServicesManager();
const extensionManager = new ExtensionManager({
commandsManager,
servicesManager,
});
```
The `ExtensionManager` only has a few public members:
- `registerExtension` - Registers a single extension
- `registerExtensions` - Registers an array of extensions
- `modules` - An object containing registered extensions by `MODULE_TYPE`
During registration, lifecycle hooks and modules have access to
`ExtensionManager`'s `ServicesManager` and `CommandsManager`.
Our `@ohif/viewer` uses the `modules` member to access registered extensions at
appropriate places in our application.
## Maintained Extensions ## Maintained Extensions
A small number of powerful extensions for popular use cases are maintained by A small number of powerful extensions for popular use cases are maintained by