Class PluginRegistry<T>

Plugin registry.

Type Parameters

  • T = any

Constructors

Properties

_application: any = null
_plugins: Map<string, IPluginData<T>> = ...
_services: Map<Token<any>, string> = ...
_validatePlugin: ((plugin) => boolean) = ...

Type declaration

    • (plugin): boolean
    • Parameters

      Returns boolean

Accessors

Methods

  • Activate the plugin with the given ID.

    Parameters

    • id: string

      The ID of the plugin of interest.

    Returns Promise<void>

    A promise which resolves when the plugin is activated or rejects with an error if it cannot be activated.

  • Deactivate the plugin and its downstream dependents if and only if the plugin and its dependents all support deactivate.

    Parameters

    • id: string

      The ID of the plugin of interest.

    Returns Promise<string[]>

    A list of IDs of downstream plugins deactivated with this one.

  • Deregister a plugin with the application.

    Parameters

    • id: string

      The ID of the plugin of interest.

    • Optional force: boolean

      Whether to deregister the plugin even if it is active.

    Returns void

  • Get a plugin description.

    Parameters

    • id: string

      The ID of the plugin of interest.

    Returns string

    The plugin description.

  • Test whether a plugin is registered with the application.

    Parameters

    • id: string

      The ID of the plugin of interest.

    Returns boolean

    true if the plugin is registered, false otherwise.

  • Test whether a plugin is activated with the application.

    Parameters

    • id: string

      The ID of the plugin of interest.

    Returns boolean

    true if the plugin is activated, false otherwise.

  • List the IDs of the plugins registered with the application.

    Returns string[]

    A new array of the registered plugin IDs.

  • Register a plugin with the application.

    Parameters

    • plugin: IPlugin<T, any>

      The plugin to register.

      Notes

      An error will be thrown if a plugin with the same ID is already registered, or if the plugin has a circular dependency.

      If the plugin provides a service which has already been provided by another plugin, the new service will override the old service.

    Returns void

  • Register multiple plugins with the application.

    Parameters

    • plugins: IPlugin<T, any>[]

      The plugins to register.

      Notes

      This calls registerPlugin() for each of the given plugins.

    Returns void

  • Resolve an optional service of a given type.

    Type Parameters

    • U

    Parameters

    • token: Token<U>

      The token for the service type of interest.

    Returns Promise<null | U>

    A promise which resolves to an instance of the requested service, or null if it cannot be resolved.

    Notes

    Services are singletons. The same instance will be returned each time a given service token is resolved.

    If the plugin which provides the service has not been activated, resolving the service will automatically activate the plugin.

    User code will not typically call this method directly. Instead, the optional services for the user's plugins will be resolved automatically when the plugin is activated.

  • Resolve a required service of a given type.

    Type Parameters

    • U

    Parameters

    • token: Token<U>

      The token for the service type of interest.

    Returns Promise<U>

    A promise which resolves to an instance of the requested service, or rejects with an error if it cannot be resolved.

    Notes

    Services are singletons. The same instance will be returned each time a given service token is resolved.

    If the plugin which provides the service has not been activated, resolving the service will automatically activate the plugin.

    User code will not typically call this method directly. Instead, the required services for the user's plugins will be resolved automatically when the plugin is activated.