Skip to main content

Function: getOrCreateVariablePackage()

function getOrCreateVariablePackage(
workspace,
id,
opt_name?,
opt_type?
): IVariableModel<IVariableState>;

Defined in: packages/blockly/core/variables.ts:663

Helper function to look up or create a variable on the given workspace. If no variable exists, creates and returns it.

Parameters

ParameterTypeDescription
workspaceWorkspaceThe workspace to search for the variable. It may be a flyout workspace or main workspace.
idstring | nullThe ID to use to look up or create the variable, or null.
opt_name?stringThe string to use to look up or create the variable.
opt_type?stringThe type to use to look up or create the variable.

Returns

IVariableModel<IVariableState>

The variable corresponding to the given ID or name + type combination.