Built-in State Variables
Table of contents
Here’s a list of state variable types built into MVCS:
These SV types will schedule the execution of the Model followed by synchronization of the View when changed. Instances of Input SV types will have an isInput property set to true. Instances of Output SV types will have an isOutput property set to true.
The Numeric input and output types support formatted Numbers. Instances of Numeric input or output SV types will have an isNumber property set to true. Instances of Numeric input or output SV types that have a unit subName will have an isUnit property set to true and may be displayed with the unit abbreviation if requested.
The input mechanism can be a keyboard, a popup keypad, or a popup thumbwheel.
numericInput
An Input SV type that displays a number input box when rendered. If the state variable has an optional unit subName, the unit abbreviation can be displayed after the input area, if requested.
numericOutput
An Output SV type that displays a number output field when rendered. If the state variable has an optional unit subName, the unit abbreviation can be displayed after the input area, if requested.
Unit input and output types have two or more Numeric subSvs, one for each alternate unit specified. The numeric subSvs are published and may be referred to separately. Assigning to one of the subSvs will update the others to the updated value converted into the respective units. Unit input and output types have a specified unitClass. The unit displayed is the current unit as selected by the unitSelector state variable that is assigned the same unitClass.
Unit input and output types have an isParent and isUnitParent property that will both be true.
unitInput
When rendered, it will display the Numeric input subSV selected by the current value of the unitSelector state variable associated with the unitInput state variable's unitClass.
unitOutput
When rendered, it will display the Numeric output subSV selected by the current value of the unitSelector state variable associated with the unitOutput state variable's unitClass.
Selector input types will have an isSelector property set to true.
dataSelectorInput
A Selector SV type that displays an editable list when rendered. The value is one of the values of the associated options. The displayed text is the text associated with each option. The state variable has an associated list of other state variables that are saved with each list item and whose values are restored when the item is selected.
selectorInput
A Selector SV type that displays a drop-down selector or radio buttons when rendered. The value is one of the values of the associated options. The displayed text is the text associated with each option.
unitSelector
A Selector SV type that displays a drop-down selector of units. The state variable has a unitClass, and the value of the unitSelector will control how the unitInput and unitOutput state variables with the same unitClass are displayed. The unitSelector input type has an isUnitCtl property that is set to true.
ageOutput
An Output SV type that displays as a string output field in hh:mm time format. The value is an age in minutes. The age is updated every minute.
booleanInput
An Input SV type that displays as a checkbox when rendered. The value is a Boolean.
canvas
An Output SV type that displays an HTML canvas. The value is a function that takes a DOM Canvas object as an argument. The function is called to re-render the canvas whenever the value is assigned.
emailInput
An Input SV type that displays as an email address input box when rendered. The value is a String.
internalObject
A Model SV type that has a value that is any JavaScript type, but is usually an Object. The value is considered changed whenever a value is assigned, even if the new value is the same.
internalValue
A Model SV type whose value can be any JavaScript type, but is usually a primitive value. The value is considered changed whenever the assigned value is different (using Object.is()) than the previous one.
template
Displays the SV value as a View Template. The value is a String, Template, or an array of Strings or Templates. The template is re-rendered whenever the value changes.
textInput
An Input SV type that displays a text input box when rendered. The value is a String.
textOutput
An Output SV type that displays a text output field when rendered. The value is a String.
timeOutput
An Output SV type that displays as a string output field in hh:mm time format. The value is a time interval in minutes.
These SV types will schedule synchronization of the View when changed. Do not use these types if any Model input depends on it. It may be used within components for state that affects the displayed contents.
viewValue
A View SV type that can have a value that is any JavaScript type but is usually a primitive value. The value is considered changed whenever the assigned value is different (using Object.is()).
viewObject
A View SV type that has a value that is any JavaScript type, but is usually an Object. The value is considered changed whenever a value is assigned, even if the new value is the same as the previous one.
StateVar
This type will not schedule the Model or View. Do not use this type if any Model input depends on it or if any component sync() method depends on being scheduled after the value changes. It may be used for state unrelated to Model execution or View synchronization or for internal values that should be saved.