Skip to main content

Interface: IVariableMap<T>

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:16

Variable maps are container objects responsible for storing and managing the set of variables referenced on a workspace.

Any of these methods may define invariants about which names and types are legal, and throw if they are not met.

Type Parameters​

Type Parameter
T extends IVariableModel<IVariableState>

Methods index​

MethodDescription
getVariableById-
getVariableReturns the variable with the given name, or null if not found. If type is provided, the variable's type must also match, or null should be returned.
getAllVariables-
getVariablesOfTypeReturns a list of all of the variables of the given type managed by this variable map.
getTypesReturns a list of the set of types of the variables managed by this variable map.
createVariableCreates a new variable with the given name. If ID is not specified, the variable map should create one. Returns the new variable.
addVariable-
renameVariableChanges the name of the given variable to the name provided and returns the renamed variable.
changeVariableType-
deleteVariable-
clear-

Methods​

getVariableById()​

getVariableById(id): T | null;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:18

Parameters​

ParameterType
idstring

Returns​

T | null


getVariable()​

getVariable(name, type?): T | null;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:25

Returns the variable with the given name, or null if not found. If type is provided, the variable's type must also match, or null should be returned.

Parameters​

ParameterType
namestring
type?string

Returns​

T | null


getAllVariables()​

getAllVariables(): T[];

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:28

Returns​

T[]


getVariablesOfType()​

getVariablesOfType(type): T[];

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:34

Returns a list of all of the variables of the given type managed by this variable map.

Parameters​

ParameterType
typestring

Returns​

T[]


getTypes()​

getTypes(): string[];

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:40

Returns a list of the set of types of the variables managed by this variable map.

Returns​

string[]


createVariable()​

createVariable(
name,
type?,
id?
): T;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:46

Creates a new variable with the given name. If ID is not specified, the variable map should create one. Returns the new variable.

Parameters​

ParameterType
namestring
type?string
id?string | null

Returns​

T


addVariable()​

addVariable(variable): void;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:49

Parameters​

ParameterType
variableT

Returns​

void


renameVariable()​

renameVariable(variable, newName): T;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:55

Changes the name of the given variable to the name provided and returns the renamed variable.

Parameters​

ParameterType
variableT
newNamestring

Returns​

T


changeVariableType()​

changeVariableType(variable, newType): T;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:58

Parameters​

ParameterType
variableT
newTypestring

Returns​

T


deleteVariable()​

deleteVariable(variable): void;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:61

Parameters​

ParameterType
variableT

Returns​

void


clear()​

clear(): void;

Defined in: packages/blockly/core/interfaces/i_variable_map.ts:64

Returns​

void