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
| Method | Description |
|---|---|
| getVariableById | - |
| getVariable | 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. |
| getAllVariables | - |
| getVariablesOfType | Returns a list of all of the variables of the given type managed by this variable map. |
| getTypes | Returns a list of the set of types of the variables managed by this variable map. |
| createVariable | Creates a new variable with the given name. If ID is not specified, the variable map should create one. Returns the new variable. |
| addVariable | - |
| renameVariable | Changes 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
| Parameter | Type |
|---|---|
id | string |
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
| Parameter | Type |
|---|---|
name | string |
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
| Parameter | Type |
|---|---|
type | string |
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
| Parameter | Type |
|---|---|
name | string |
type? | string |
id? | string | null |
Returns
T
addVariable()
addVariable(variable): void;
Defined in: packages/blockly/core/interfaces/i_variable_map.ts:49
Parameters
| Parameter | Type |
|---|---|
variable | T |
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
| Parameter | Type |
|---|---|
variable | T |
newName | string |
Returns
T
changeVariableType()
changeVariableType(variable, newType): T;
Defined in: packages/blockly/core/interfaces/i_variable_map.ts:58
Parameters
| Parameter | Type |
|---|---|
variable | T |
newType | string |
Returns
T
deleteVariable()
deleteVariable(variable): void;
Defined in: packages/blockly/core/interfaces/i_variable_map.ts:61
Parameters
| Parameter | Type |
|---|---|
variable | T |
Returns
void
clear()
clear(): void;
Defined in: packages/blockly/core/interfaces/i_variable_map.ts:64
Returns
void