Skip to main content

Class: PluginSystem<T, B>

A system that handles the registration and boostrapping of plugin scripts.

Type parameters

NameType
Textends AvionicsPlugin<B>
BB

Constructors

constructor

new PluginSystem<T, B>(): PluginSystem<T, B>

Ctor

Type parameters

NameType
Textends AvionicsPlugin<B>
BB

Returns

PluginSystem<T, B>

Defined in

src/sdk/components/FSComponent.ts:1242

Properties

binder

Optional binder: B

The avionics specific plugin binder to inject into each plugin.

Defined in

src/sdk/components/FSComponent.ts:1224


createdHandlers

Readonly createdHandlers: (component: DisplayComponent<any, []>) => void[] = []

An event subscribable that publishes when a new component is created.

Defined in

src/sdk/components/FSComponent.ts:1230


creatingHandlers

Readonly creatingHandlers: (constructor: DisplayComponentFactory<any, []>, props: any) => undefined | DisplayComponent<any, []>[] = []

An event subscribable that publishes when a new component is about to be created.

Defined in

src/sdk/components/FSComponent.ts:1227


renderedHandlers

Readonly renderedHandlers: (node: VNode) => void[] = []

An event subscribable that publishes when a component has finished rendering.

Defined in

src/sdk/components/FSComponent.ts:1233

Methods

addPlugin

addPlugin(plugin): void

Adds a plugin to the plugin system.

Parameters

NameTypeDescription
pluginTThe plugin to add.

Returns

void

Defined in

src/sdk/components/FSComponent.ts:1339


addScripts

addScripts(document, instrumentId, globalPluginTargetFunc): Promise<void>

Adds plugin scripts to load to the system.

Parameters

NameTypeDescription
documentXMLDocumentThe panel.xml document to load scripts from.
instrumentIdstringThe ID of the instrument.
globalPluginTargetFunc(target: string) => booleanA function that returns true if a global plugin should be loaded.

Returns

Promise<void>

Example

await this.pluginSystem.addScripts(this.instrument.xmlConfig, this.instrument.templateID, (target) => {
return target === this.instrument.templateID;
});

Defined in

src/sdk/components/FSComponent.ts:1260


callPlugins

callPlugins(fun): void

Runs the provided function on all of the registered plugins.

Parameters

NameTypeDescription
fun(plugin: T) => voidThe function to run.

Returns

void

Defined in

src/sdk/components/FSComponent.ts:1347


onComponentCreated

onComponentCreated(component): void

A hook that allows plugins to observe components as they are created.

Parameters

NameTypeDescription
componentDisplayComponent<any, []>The component that was created.

Returns

void

Defined in

src/sdk/components/FSComponent.ts:1391


onComponentCreating

onComponentCreating(constructor, props): undefined | DisplayComponent<any, []>

A hook that allows plugins to replace components that are about to be created with their own implementations.

Parameters

NameTypeDescription
constructorDisplayComponentFactory<any, []>The display component constructor that is going to be used.
propsanyThe component props that will be passed into the component.

Returns

undefined | DisplayComponent<any, []>

Returns either the display component that will replace, or undefined if the component should not be replaced.

Defined in

src/sdk/components/FSComponent.ts:1367


onComponentRendered

onComponentRendered(node): void

A hook that allows plugins to observe built VNodes after they are rendered.

Parameters

NameTypeDescription
nodeVNodeThe node that was rendered.

Returns

void

Defined in

src/sdk/components/FSComponent.ts:1409


startSystem

startSystem(binder): Promise<void>

Starts the plugin system with the included avionics specific plugin binder.

Parameters

NameTypeDescription
binderBThe plugin binder to pass to the individual plugins.

Returns

Promise<void>

Defined in

src/sdk/components/FSComponent.ts:1310


subscribeOnComponentCreated

subscribeOnComponentCreated(handler): void

Subscribes a handler to the component created hook.

Parameters

NameTypeDescription
handler(component: DisplayComponent<any, []>) => voidThe handler to subscribe.

Returns

void

Defined in

src/sdk/components/FSComponent.ts:1383


subscribeOnComponentCreating

subscribeOnComponentCreating(handler): void

Subscribes a handler to the component creating hook.

Parameters

NameTypeDescription
handler(constructor: DisplayComponentFactory<any, []>, props: any) => undefined | DisplayComponent<any, []>The handler to subscribe.

Returns

void

Defined in

src/sdk/components/FSComponent.ts:1357


subscribeOnComponentRendered

subscribeOnComponentRendered(handler): void

Subscribes a handler to the component rendered hook.

Parameters

NameTypeDescription
handler(node: VNode) => voidThe handler to subscribe.

Returns

void

Defined in

src/sdk/components/FSComponent.ts:1401