Variable Base
This node provides the foundational functionality for all variable node types.
The Variable Base node serves as the base class for creating typed variable nodes.
The Variable Base node is an abstract base class that provides common functionality for all variable node types (Boolean, Number, String, etc.). It defines the standard interface and behavior patterns used across all variable implementations.
Core Functionality
Standard Interface
All variable nodes derived from Variable Base provide:
- Value Storage: Persistent state management
- Get/Set Operations: Standard value access patterns
- Change Events: Notifications when values update
- Type Casting: Automatic conversion to appropriate data types
Common Features
- State Persistence: Values persist across application sessions
- Change Detection: Automatic change event triggering
- Type Safety: Ensures values match expected data types
- Default Values: Proper initialization with type-appropriate defaults
Implementation Pattern
Variable Base uses a factory pattern to create specific variable types:
// Creates a typed variable definition
VariableBase.createDefinition({
name: 'TypeName',
startValue: defaultValue,
type: { name: 'typeName' },
cast: function(value) {
// Type conversion logic
}
});
Usage in Development
Variable Base is not used directly but provides the foundation for:
- Boolean Variable: True/false state management
- Number Variable: Numeric value storage
- String Variable: Text value management
- Custom Variables: Extended variable types with specific behaviors
This abstraction ensures consistency across all variable types while allowing for type-specific optimizations and behaviors.