Stay organized with collections
Save and categorize content based on your preferences.
blockly > VariableModel
VariableModel class
Class for a variable model. Holds information for the variable including name, ID, and type.
Signature:
export declare class VariableModel implements IVariableModel<IVariableState>
Implements: IVariableModel<IVariableState>
Constructors
Methods
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eVariableModel\u003c/code\u003e class stores information about a variable, including its name, ID, and type.\u003c/p\u003e\n"],["\u003cp\u003eIt has a constructor to create new instances and methods to manage its properties.\u003c/p\u003e\n"],["\u003cp\u003eKey properties include \u003ccode\u003ename\u003c/code\u003e, \u003ccode\u003etype\u003c/code\u003e, and the \u003ccode\u003eworkspace\u003c/code\u003e it belongs to.\u003c/p\u003e\n"],["\u003cp\u003eYou can access the variable's unique identifier with the \u003ccode\u003egetId()\u003c/code\u003e method.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [VariableModel](./blockly.variablemodel_class.md)\n\nVariableModel class\n-------------------\n\nClass for a variable model. Holds information for the variable including name, ID, and type.\n\n**Signature:** \n\n export declare class VariableModel implements IVariableModel\u003cIVariableState\u003e \n\n**Implements:** [IVariableModel](./blockly.ivariablemodel_interface.md)\\\u003c[IVariableState](./blockly.ivariablestate_interface.md)\\\u003e\n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|------------------------------------------------------------------------------------------------------------------|-----------|--------------------------------------------------------|\n| [(constructor)(workspace, name, opt_type, opt_id)](./blockly.variablemodel_class._constructor__1_constructor.md) | | Constructs a new instance of the `VariableModel` class |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|--------------------------------------------------------------------------|-----------|-----------------------------------------------------------------------|\n| [getId()](./blockly.variablemodel_class.getid_1_method.md) | | |\n| [getName()](./blockly.variablemodel_class.getname_1_method.md) | | |\n| [getType()](./blockly.variablemodel_class.gettype_1_method.md) | | |\n| [getWorkspace()](./blockly.variablemodel_class.getworkspace_1_method.md) | | Returns the workspace this VariableModel belongs to. |\n| [load(state, workspace)](./blockly.variablemodel_class.load_1_method.md) | `static` | Loads the persisted state into a new variable in the given workspace. |\n| [save()](./blockly.variablemodel_class.save_1_method.md) | | Serializes this VariableModel. |\n| [setName(newName)](./blockly.variablemodel_class.setname_1_method.md) | | Updates the user-visible name of this variable. |\n| [setType(newType)](./blockly.variablemodel_class.settype_1_method.md) | | Updates the type of this variable. |"]]