class
Components::Reactive::ReactiveHandler
- Components::Reactive::ReactiveHandler
- Reference
- Object
Overview
HTTP Handler for reactive components This handler can be added to any Crystal web framework's middleware pipeline
Example usage in Amber: pipeline :web do plug Components::Reactive::ReactiveHandler.new end
The handler manages:
- WebSocket connections for real-time updates
- HTTP POST requests for component actions (non-WebSocket fallback)
- Component lifecycle and state management
Included Modules
- HTTP::Handler
Defined in:
components/reactive/reactive_handler.crConstructors
Class Method Summary
- .active_sessions : Int32
- .broadcast_update(component_id : String, html : String, state : JSON::Any | Nil = nil) : Nil
-
.register_component(component : Component) : Nil
Public API for managing components
- .registered_components : Int32
- .send_to_session(session_id : String, message : Hash | NamedTuple) : Nil
- .unregister_component(component_id : String) : Nil
Instance Method Summary
- #action_path_prefix : String
- #action_path_prefix=(action_path_prefix : String)
- #call(context) : Nil
- #enable_http_fallback : Bool
- #enable_http_fallback=(enable_http_fallback : Bool)
-
#websocket_path : String
Configuration
-
#websocket_path=(websocket_path : String)
Configuration
Constructor Detail
def self.new(websocket_path : String = "/components/ws", action_path_prefix : String = "/components/action", enable_http_fallback : Bool = true)
#
Class Method Detail
def self.broadcast_update(component_id : String, html : String, state : JSON::Any | Nil = nil) : Nil
#
Public API for managing components