Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IPlugin<T, U>

A user-defined application plugin.

Notes

Plugins are the foundation for building an extensible application.

Plugins consume and provide "services", which are nothing more than concrete implementations of interfaces and/or abstract types.

Unlike regular imports and exports, which tie the service consumer to a particular implementation of the service, plugins decouple the service producer from the service consumer, allowing an application to be easily customized by third parties in a type-safe fashion.

Type parameters

  • T

  • U

Hierarchy

  • IPlugin

Index

Properties

activate

activate: function

A function invoked to activate the plugin.

param

The application which owns the plugin.

param

The services specified by the requires property.

returns

The provided service, or a promise to the service.

Notes

This function will be called whenever the plugin is manually activated, or when another plugin being activated requires the service it provides.

This function will not be called unless all of its required services can be fulfilled.

Type declaration

    • (app: T, ...args: any[]): U | Promise<U>
    • Parameters

      • app: T
      • Rest ...args: any[]

      Returns U | Promise<U>

Optional autoStart

autoStart: boolean

Whether the plugin should be activated on application start.

Notes

The default is false.

id

id: string

The human readable id of the plugin.

Notes

This must be unique within an application.

Optional optional

optional: Token<any>[]

The types of optional services for the plugin, if any.

Notes

These tokens correspond to the services that can be used by the plugin if available, but are not necessarily required.

The optional services will be passed to the activate() function following all required services. If an optional service cannot be resolved, null will be passed in its place.

Optional provides

provides: Token<U>

The type of service provided by the plugin, if any.

Notes

This token corresponds to the service exported by the plugin.

When the plugin is activated, the return value of activate() is used as the concrete instance of the type.

Optional requires

requires: Token<any>[]

The types of required services for the plugin, if any.

Notes

These tokens correspond to the services that are required by the plugin for correct operation.

When the plugin is activated, a concrete instance of each type will be passed to the activate() function, in the order they are specified in the requires array.

Generated using TypeDoc