Dynamically typed variable getters and setters #1281
Labels
component: developer apis
component: variables
help wanted
External contributions actively solicited
issue: feature request
Describes a new feature and why it should be added
Blockly should provide two additional blocks:
variables_get_dynamic
andvariables_set_dynamic
. These blocks should dynamically change the types on their output/input connections based on the type of the currently selected variable.We should also provide a custom tag for toolbox categories that populates the toolbox with the dynamic variable blocks instead of the standard ones. Probably
VARIABLES_DYNAMIC
.Why: It is now possible to create variables with different types, and to get the type of the currently selected variable. In general on blocks with typed variable fields we can't infer the type of the output statically, but we can infer it dynamically for the general getter and setter blocks. This saves developers from having to make separate getters and setters for each variable type they create. (They still may want to in order to be explicit about their types.)
Why create new blocks instead of changing
variables_get
andvariables_set
: backwards compatibility.These blocks will have the same shape as the
variables_get
andvariables_set
blocks:They will have the same basic definitions as the
variables_get
andvariables_set
blocks (see below) but have onchange handlers to set their connection types appropriately.The text was updated successfully, but these errors were encountered: