The Plugin Type
What is a plugin?
If you're creating a plugin, it is highly recommended you use TypeScript and take advantage of the Plugin
type.
How to use the Plugin
Type
Plugin
TypeComplex Example Plugin
The Plugin
type is a generic type, taking in up to five total generic parameters. A Plugin using all five parameters would look like this:
This type describes a plugin named 'Complex'
that implements the Store Control Plane, as well as the method foo
. This plugin is also dependent on plugins that implement the ID Control Plane, as well as the method bar.
Let's break down what each of these arguments are doing one at a time.
Arg 1: Name
This argument simply names a plugin. It is a required string, and is used by some Control Planes.
Specifying a name will force objects that have been set to this type to use that name!
Arg 2: Planes Implemented
This argument specifies which Control Planes the plugin implements. It can be:
any
ornever
, which specifies that this plugin does not implement any Control PlanesA single string (such as used in the example above), which specifies that this plugin implements a single Control Plane
A union of strings (e.g.
'store' | 'read'
), which specifies that this plugin implements multiple Control Planes
This argument defaults to any
, specifying that this plugin does not implement any Control Planes.
Specifying one or more Control Planes implemented will force objects that have been set to this type to implement those planes!
Arg 3: Methods Implemented
This argument specifies which methods the plugin implements. It is an object whose values are functions.
This argument defaults to Record<never, never>
, specifying that this plugin does not implement any methods.
Specifying methods implemented will force objects that have been set to this type to implement those methods!
Arg 4: Dependent Planes
This argument specifies which Control Planes the plugin depends on. It can be:
any
ornever
, which specifies that this plugin does not depend on any Control PlanesA single string (such as used in the example above), which specifies that this plugin depends on a single Control Plane
A union of strings (e.g.
'store' | 'read'
), which specifies that this plugin depends on multiple Control Planes
This argument defaults to never
, specifying that this plugin does not depend on any Control Planes.
Specifying one or more Dependent Control Planes will add those planes to the implicit LearnCard passed into each plugin method!
Specifying Dependent Planes here will not force LearnCards to implement those planes when adding this plugin! Please see Depending on Plugins for more information.
Arg 5: Dependent Methods
This argument specifies which methods the plugin depends on. It is an object whose values are functions.
This argument defaults to Record<never, never>
, specifying that this plugin does not depend on any methods.
Specifying dependent methods will add those methods to the implicit LearnCard passed into each plugin method!
Specifying Dependent Methods here will not force LearnCards
to implement those methods when adding this plugin! Please see Depending on Plugins for more information.
Last updated