class Components::Examples::ChatComponent

Overview

Real-time chat component

Defined in:

components/examples/chat_component.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Components::Reactive::ReactiveComponent

auto_update : Bool auto_update, auto_update=(auto_update : Bool) auto_update=, broadcast_update : Nil broadcast_update, handle_action(action : String, data : JSON::Any) : Nil handle_action, push_update : Nil push_update, register : Nil register, render : SafeHTML render, set_state(key : String, value : JSON::Any) : Nil set_state, unregister : Nil unregister, update_state(&block : -> Nil) : Nil update_state

Macros inherited from class Components::Reactive::ReactiveComponent

on_action(action_name, &block) on_action, on_event(event_name, &block) on_event

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) : Nil
set_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

Constructor methods inherited from class Components::StatefulComponent

new(**attrs) new

Instance methods inherited from class Components::Component

<<(child : Component | Elements::HTMLElement | String | Elements::RawHTML) : self <<, [](name : String) : String | Nil [], []=(name : String, value : String) : String []=, add_children(*children : Component | Elements::HTMLElement | String | Elements::RawHTML) : self add_children, attributes : Hash(String, String) attributes, build(&block : self -> Nil) : self build, children : Array(Component | Elements::HTMLElement | String | Elements::RawHTML) children, component_id : String component_id, render : SafeHTML render, render_content : String render_content, render_safe_content : SafeHTML render_safe_content, to_raw_html : Elements::RawHTML to_raw_html, to_s(io : IO) : Nil to_s

Constructor methods inherited from class Components::Component

new(**attrs) new

Macros inherited from class Components::Component

component_css(css_string) component_css

Constructor Detail

def self.new(**attrs) #

[View source]

Class Method Detail

def self.component_css_string : String #

[View source]

Instance Method Detail

def receive_message(message : JSON::Any) #

Receive a message from another user


[View source]
def render_content : String #
Description copied from class Components::Component

Abstract method to be implemented by subclasses


[View source]
def send_message(event : JSON::Any) #

Send a message


[View source]
def update_draft(event : JSON::Any) #

Update draft message as user types


[View source]