class Components::Reactive::ReactiveHandler

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:

  1. WebSocket connections for real-time updates
  2. HTTP POST requests for component actions (non-WebSocket fallback)
  3. Component lifecycle and state management

Included Modules

Defined in:

components/reactive/reactive_handler.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(websocket_path : String = "/components/ws", action_path_prefix : String = "/components/action", enable_http_fallback : Bool = true) #

[View source]

Class Method Detail

def self.active_sessions : Int32 #

[View source]
def self.broadcast_update(component_id : String, html : String, state : JSON::Any | Nil = nil) : Nil #

[View source]
def self.register_component(component : Component) : Nil #

Public API for managing components


[View source]
def self.registered_components : Int32 #

[View source]
def self.send_to_session(session_id : String, message : Hash | NamedTuple) : Nil #

[View source]
def self.unregister_component(component_id : String) : Nil #

[View source]

Instance Method Detail

def action_path_prefix : String #

[View source]
def action_path_prefix=(action_path_prefix : String) #

[View source]
def call(context) : Nil #

[View source]
def enable_http_fallback : Bool #

[View source]
def enable_http_fallback=(enable_http_fallback : Bool) #

[View source]
def websocket_path : String #

Configuration


[View source]
def websocket_path=(websocket_path : String) #

Configuration


[View source]