HelloWorldController

Hello World Stimulus Controller

This controller demonstrates the Stimulus.js pattern used in KMP plugins. Stimulus controllers provide interactive behavior for frontend components without requiring a full JavaScript framework.

Key Concepts:

  • Targets: DOM elements the controller interacts with
  • Values: Properties that can be set from HTML attributes
  • Actions: Event handlers triggered by user interaction
  • Outlets: Connections to other Stimulus controllers

Usage in HTML:

Methods

clear()

Clear action - Clear the output Triggered by: data-action="click->hello-world#clear"

clear()

Clear action - Clear the output Triggered by: data-action="click->hello-world#clear"

connect()

Connect the controller to the DOM Called when the controller is connected to the DOM

connect()

Connect the controller to the DOM Called when the controller is connected to the DOM

countValueChanged()

Value changed callback - Called when count value changes Automatically called when countValue is updated

countValueChanged()

Value changed callback - Called when count value changes Automatically called when countValue is updated

disconnect()

Disconnect the controller from the DOM Called when the controller is disconnected from the DOM Use for cleanup (removing event listeners, timers, etc.)

disconnect()

Disconnect the controller from the DOM Called when the controller is disconnected from the DOM Use for cleanup (removing event listeners, timers, etc.)

(async) fetchData()

Example of an async method - fetch data from server

(async) fetchData()

Example of an async method - fetch data from server

greet()

Greet action - Display a greeting message Triggered by: data-action="click->hello-world#greet"

greet()

Greet action - Display a greeting message Triggered by: data-action="click->hello-world#greet"

initialize()

Initialize the controller Called once when the controller is first instantiated

initialize()

Initialize the controller Called once when the controller is first instantiated

messageValueChanged()

Value changed callback - Called when message value changes Automatically called when messageValue is updated

messageValueChanged()

Value changed callback - Called when message value changes Automatically called when messageValue is updated

showMessage()

Example of a method that could be called from other controllers or JavaScript code

showMessage()

Example of a method that could be called from other controllers or JavaScript code

updateCounter()

Update the counter display

updateCounter()

Update the counter display

HelloWorldController

Hello World Stimulus Controller

This controller demonstrates the Stimulus.js pattern used in KMP plugins. Stimulus controllers provide interactive behavior for frontend components without requiring a full JavaScript framework.

Key Concepts:

  • Targets: DOM elements the controller interacts with
  • Values: Properties that can be set from HTML attributes
  • Actions: Event handlers triggered by user interaction
  • Outlets: Connections to other Stimulus controllers

Usage in HTML:

Methods

clear()

Clear action - Clear the output Triggered by: data-action="click->hello-world#clear"

clear()

Clear action - Clear the output Triggered by: data-action="click->hello-world#clear"

connect()

Connect the controller to the DOM Called when the controller is connected to the DOM

connect()

Connect the controller to the DOM Called when the controller is connected to the DOM

countValueChanged()

Value changed callback - Called when count value changes Automatically called when countValue is updated

countValueChanged()

Value changed callback - Called when count value changes Automatically called when countValue is updated

disconnect()

Disconnect the controller from the DOM Called when the controller is disconnected from the DOM Use for cleanup (removing event listeners, timers, etc.)

disconnect()

Disconnect the controller from the DOM Called when the controller is disconnected from the DOM Use for cleanup (removing event listeners, timers, etc.)

(async) fetchData()

Example of an async method - fetch data from server

(async) fetchData()

Example of an async method - fetch data from server

greet()

Greet action - Display a greeting message Triggered by: data-action="click->hello-world#greet"

greet()

Greet action - Display a greeting message Triggered by: data-action="click->hello-world#greet"

initialize()

Initialize the controller Called once when the controller is first instantiated

initialize()

Initialize the controller Called once when the controller is first instantiated

messageValueChanged()

Value changed callback - Called when message value changes Automatically called when messageValue is updated

messageValueChanged()

Value changed callback - Called when message value changes Automatically called when messageValue is updated

showMessage()

Example of a method that could be called from other controllers or JavaScript code

showMessage()

Example of a method that could be called from other controllers or JavaScript code

updateCounter()

Update the counter display

updateCounter()

Update the counter display