Skip to main content

State Manager

This node manages dynamic state values with configurable inputs and batch updates.

The State Manager node provides centralized state management with dynamic input creation and controlled update propagation.

The State Manager node enables flexible state management by accepting dynamic inputs and outputting their values when triggered. It supports configurable input counts, aliases, and batch state updates for complex state management scenarios.

Inputs

Configuration

DataDescription
Number of InputsHow many dynamic inputs to create (default: 3)

Control

SignalDescription
UpdateTriggers state update and output propagation
ResetResets all state values to their defaults

Dynamic Inputs

Additional numbered inputs are created based on the Number of Inputs setting

Outputs

Control

SignalDescription
UpdatedTriggered when state update completes
Reset DoneTriggered when reset operation completes

Dynamic Outputs

Outputs are created corresponding to each dynamic input

Usage

The State Manager node provides centralized state management for complex applications:

Dynamic Input Creation

Configure the Number of Inputs to automatically create numbered input ports:

  • Input 1, Input 2, Input 3, etc.
  • Each input can accept any data type
  • Corresponding outputs are created automatically

State Update Pattern

  1. Collect State: Connect various data sources to dynamic inputs
  2. Batch Update: Trigger Update signal to propagate all values
  3. Access State: Read current values from corresponding outputs
  4. Reset When Needed: Use Reset to clear all state values

Example Use Cases

  1. Form State Management: Collect form field values and batch update

    Input 1: Username field
    Input 2: Email field
    Input 3: Settings object

    Update: All form state propagated to outputs
  2. Game State: Manage player stats and game variables

    Input 1: Player health
    Input 2: Score
    Input 3: Level data
    Input 4: Inventory

    Update: All game state synchronized
  3. Dashboard Data: Collect metrics from multiple sources

    Input 1: Sales data
    Input 2: User analytics
    Input 3: Performance metrics

    Update: Dashboard refreshed with latest data
  4. Configuration Management: Handle application settings

    Input 1: User preferences
    Input 2: Theme settings
    Input 3: API configuration

    Update: Settings applied across application

Aliasing System

The State Manager supports aliases for more meaningful input/output names:

  • Create custom aliases instead of numbered inputs
  • Improves code readability and maintainability
  • Allows semantic naming for state properties

State Persistence

  • Maintain Values: State values persist between updates
  • Selective Updates: Only changed values trigger outputs
  • Batch Operations: All updates happen atomically
  • Reset Capability: Clear all state with single operation

Advanced Patterns

Conditional Updates: Use logic nodes to conditionally trigger updates State Validation: Validate state before updates using condition nodes Nested State: Use objects as input values for complex state structures State History: Combine with arrays to maintain state history

Performance Considerations

  • Batch Updates: Minimize update frequency for better performance
  • State Size: Monitor memory usage with large state objects
  • Output Dependencies: Consider which outputs actually need the data
  • Update Timing: Coordinate updates with UI render cycles

Integration with Other Nodes

With Forms: Collect form data before submission With APIs: Batch state before making API calls With UI: Update multiple UI elements simultaneously With Storage: Persist state to local storage or databases

Best Practices

  1. Meaningful Names: Use aliases for better code documentation
  2. State Structure: Organize related state into logical groups
  3. Update Strategy: Plan when and how often to trigger updates
  4. Error Handling: Handle invalid state values gracefully
  5. Testing: Test state transitions and edge cases thoroughly

Error Handling

The State Manager handles various error conditions:

  • Invalid input values are filtered out
  • State corruption is prevented through validation
  • Reset operations always succeed
  • Proper cleanup on node deletion