Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
feat: support preRegistration hook, and extension configuration at ti…
Browse files Browse the repository at this point in the history
…me of registration

* Remove default config for tools

* feat: support preRegistration hook, and extension configuration at time of registration

* Prefer built-in check for array
  • Loading branch information
dannyrb committed Jun 25, 2019
1 parent 9d7a997 commit 23976b9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/extensions/ExtensionManager.js
Expand Up @@ -15,21 +15,31 @@ export default class ExtensionManager {
}

/**
* An array of extensions, or an array of arrays that contains extension
* configuration pairs.
*
* @param {Object[]} extensions - Array of extensions
*/
registerExtensions(extensions) {
extensions.forEach(extension => {
this.registerExtension(extension);
const hasConfiguration = Array.isArray(extension);

if (hasConfiguration) {
const [ohifExtension, configuration] = extensions;
this.registerExtension(ohifExtension, configuration);
} else {
this.registerExtension(extension);
}
});
}

/**
*
* TODO: Id Management: SopClassHandlers currently refer to viewport module by id; setting the extension id as viewport module id is a workaround for now
* @param {Object} extension
* @param {Object} configuration
*/
registerExtension(extension) {
registerExtension(extension, configuration = {}) {
if (!extension) {
log.warn(
'Attempting to register a null/undefined extension. Exiting early.'
Expand All @@ -54,6 +64,11 @@ export default class ExtensionManager {
return;
}

// preRegistrationHook
if (extension.preRegistration) {
extension.preRegistration(configuration);
}

// Register Modules
this.moduleTypeNames.forEach(moduleType => {
const extensionModule = this._getExtensionModule(
Expand Down

0 comments on commit 23976b9

Please sign in to comment.