Skip to main content

Class: PluginSystem<T, B>

Defined in: src/sdk/components/FSComponent.ts:1249

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

Type Parameters

Type Parameter
T extends AvionicsPlugin<B>
B

Constructors

Constructor

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

Defined in: src/sdk/components/FSComponent.ts:1272

Ctor

Returns

PluginSystem<T, B>

Properties

binder?

optional binder: B

Defined in: src/sdk/components/FSComponent.ts:1254

The avionics specific plugin binder to inject into each plugin.


createdHandlers

readonly createdHandlers: (component) => void[] = []

Defined in: src/sdk/components/FSComponent.ts:1260

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

Parameters

ParameterType
componentDisplayComponent<any>

Returns

void


creatingHandlers

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

Defined in: src/sdk/components/FSComponent.ts:1257

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

Parameters

ParameterType
constructorDisplayComponentFactory<any>
propsany

Returns

undefined | DisplayComponent<any, []>


renderedHandlers

readonly renderedHandlers: (node) => void[] = []

Defined in: src/sdk/components/FSComponent.ts:1263

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

Parameters

ParameterType
nodeVNode

Returns

void

Methods

addPlugin()

addPlugin(plugin): void

Defined in: src/sdk/components/FSComponent.ts:1369

Adds a plugin to the plugin system.

Parameters

ParameterTypeDescription
pluginTThe plugin to add.

Returns

void


addScripts()

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

Defined in: src/sdk/components/FSComponent.ts:1290

Adds plugin scripts to load to the system.

Parameters

ParameterTypeDescription
documentXMLDocumentThe panel.xml document to load scripts from.
instrumentIdstringThe ID of the instrument.
globalPluginTargetFunc(target) => 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;
});

callPlugins()

callPlugins(fun, reverseOrder): void

Defined in: src/sdk/components/FSComponent.ts:1378

Runs the provided function on all of the registered plugins.

Parameters

ParameterTypeDefault valueDescription
fun(plugin) => voidundefinedThe function to run.
reverseOrderbooleanfalseWhether to iterate through plugins in reverse order. Defaults to false.

Returns

void


onComponentCreated()

onComponentCreated(component): void

Defined in: src/sdk/components/FSComponent.ts:1428

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

Parameters

ParameterTypeDescription
componentDisplayComponent<any>The component that was created.

Returns

void


onComponentCreating()

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

Defined in: src/sdk/components/FSComponent.ts:1404

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

Parameters

ParameterTypeDescription
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.


onComponentRendered()

onComponentRendered(node): void

Defined in: src/sdk/components/FSComponent.ts:1446

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

Parameters

ParameterTypeDescription
nodeVNodeThe node that was rendered.

Returns

void


startSystem()

startSystem(binder): Promise<void>

Defined in: src/sdk/components/FSComponent.ts:1340

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

Parameters

ParameterTypeDescription
binderBThe plugin binder to pass to the individual plugins.

Returns

Promise<void>


subscribeOnComponentCreated()

subscribeOnComponentCreated(handler): void

Defined in: src/sdk/components/FSComponent.ts:1420

Subscribes a handler to the component created hook.

Parameters

ParameterTypeDescription
handler(component) => voidThe handler to subscribe.

Returns

void


subscribeOnComponentCreating()

subscribeOnComponentCreating(handler): void

Defined in: src/sdk/components/FSComponent.ts:1394

Subscribes a handler to the component creating hook.

Parameters

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

Returns

void


subscribeOnComponentRendered()

subscribeOnComponentRendered(handler): void

Defined in: src/sdk/components/FSComponent.ts:1438

Subscribes a handler to the component rendered hook.

Parameters

ParameterTypeDescription
handler(node) => voidThe handler to subscribe.

Returns

void