abstract class
Components::Reactive::ReactiveComponent
- Components::Reactive::ReactiveComponent
- Components::StatefulComponent
- Components::Component
- Reference
- Object
Overview
Base class for components that support real-time updates via WebSocket
Direct Known Subclasses
Defined in:
components/reactive/reactive_component.crMacro Summary
-
on_action(action_name, &block)
Define client-side action handler
-
on_event(event_name, &block)
Subscribe to server-side events
Instance Method Summary
-
#auto_update : Bool
Whether this component should auto-update on state changes
-
#auto_update=(auto_update : Bool)
Whether this component should auto-update on state changes
-
#broadcast_update : Nil
Broadcast update to all sessions with this component
-
#handle_action(action : String, data : JSON::Any) : Nil
Handle incoming actions from client
-
#push_update : Nil
Send update to all connected clients
-
#register : Nil
Register this component with the reactive handler
-
#render : SafeHTML
Override render to include reactive data attributes
-
#set_state(key : String, value : JSON::Any) : Nil
Override state setters to trigger updates
-
#unregister : Nil
Unregister this component
-
#update_state(&block : -> Nil) : Nil
Batch state updates
Instance methods inherited from class Components::StatefulComponent
cacheable? : Bool
cacheable?,
changed? : Bool
changed?,
get_state(key : String) : JSON::Any | Nil
get_state,
mark_changed!
mark_changed!,
reset_changed
reset_changed,
reset_changed!
reset_changed!,
set_state(key : String, value : JSON::Any) : Nilset_state(key : String, value : String)
set_state(key : String, value : Int32)
set_state(key : String, value : Int64)
set_state(key : String, value : Float32)
set_state(key : String, value : Float64)
set_state(key : String, value : Bool)
set_state(key : String, value : Array(JSON::Any))
set_state(key : String, value : Hash(String, JSON::Any)) set_state, state : Hash(String, JSON::Any) state, state_to_json : JSON::Any state_to_json