Skip to main content

Class: ComponentManager

Defined in: packages/blockly/core/component_manager.ts:47

Manager for all items registered with the workspace.

Properties index​

PropertyDescription
Capability-

Methods index​

MethodDescription
addComponentAdds a component.
removeComponentRemoves a component.
addCapabilityAdds a capability to a existing registered component.
removeCapabilityRemoves a capability from an existing registered component.
hasCapabilityReturns whether the component with this id has the specified capability.
getComponentGets the component with the given ID.
getComponentsGets all the components with the specified capability.

Constructors​

Constructor​

new ComponentManager(): ComponentManager;

Returns​

ComponentManager

Properties​

Capability​

static Capability: typeof Capability;

Defined in: packages/blockly/core/component_manager.ts:48

Methods​

addComponent()​

addComponent(componentInfo, opt_allowOverrides?): void;

Defined in: packages/blockly/core/component_manager.ts:65

Adds a component.

Parameters​

ParameterTypeDescription
componentInfoComponentDatumThe data for the component to register.
opt_allowOverrides?booleanTrue to prevent an error when overriding an already registered item.

Returns​

void


removeComponent()​

removeComponent(id): void;

Defined in: packages/blockly/core/component_manager.ts:96

Removes a component.

Parameters​

ParameterTypeDescription
idstringThe ID of the component to remove.

Returns​

void


addCapability()​

addCapability<T>(id, capability): void;

Defined in: packages/blockly/core/component_manager.ts:114

Adds a capability to a existing registered component.

Type Parameters​

Type Parameter
T

Parameters​

ParameterTypeDescription
idstringThe ID of the component to add the capability to.
capabilitystring | Capability<T>The capability to add.

Returns​

void


removeCapability()​

removeCapability<T>(id, capability): void;

Defined in: packages/blockly/core/component_manager.ts:141

Removes a capability from an existing registered component.

Type Parameters​

Type Parameter
T

Parameters​

ParameterTypeDescription
idstringThe ID of the component to remove the capability from.
capabilitystring | Capability<T>The capability to remove.

Returns​

void


hasCapability()​

hasCapability<T>(id, capability): boolean;

Defined in: packages/blockly/core/component_manager.ts:173

Returns whether the component with this id has the specified capability.

Type Parameters​

Type Parameter
T

Parameters​

ParameterTypeDescription
idstringThe ID of the component to check.
capabilitystring | Capability<T>The capability to check for.

Returns​

boolean

Whether the component has the capability.


getComponent()​

getComponent(id): IComponent | undefined;

Defined in: packages/blockly/core/component_manager.ts:187

Gets the component with the given ID.

Parameters​

ParameterTypeDescription
idstringThe ID of the component to get.

Returns​

IComponent | undefined

The component with the given name or undefined if not found.


getComponents()​

getComponents<T>(capability, sorted): T[];

Defined in: packages/blockly/core/component_manager.ts:198

Gets all the components with the specified capability.

Type Parameters​

Type Parameter
T extends IComponent

Parameters​

ParameterTypeDescription
capabilitystring | Capability<T>The capability of the component.
sortedbooleanWhether to return list ordered by weights.

Returns​

T[]

The components that match the specified capability.