class

Freshen::Hub

Inherits Reference < Object

Live-Reload SSE Hub providing a unified, backwards-compatible Facade integrating the sliding-window Debouncer, Pub/Sub Broker, and Script Injector.

Constructors

new(debounce_ms : Int32 = 50, max_deadline_ms : Int32 = 250)

Initializes the hub with configurable debounce window and max deadline.

Source

Class methods

inject_script(html : String, require_body_tag : Bool = false, endpoint : String = "/_freshen/reload", script_id : String = "freshen-live-reload", nonce : String | Nil = nil, css_hot_reload : Bool = true) : String

Injects the live reload JavaScript client snippet into an HTML response.

Source
reload_script(endpoint : String = "/_freshen/reload", script_id : String = "freshen-live-reload", nonce : String | Nil = nil, css_hot_reload : Bool = true) : String

Returns the standalone client-side JavaScript snippet.

Source

Instance methods

active_client_count

Returns the number of currently connected SSE clients.

Source
broadcast_reload

Immediately broadcasts an SSE reload event payload to all connected clients.

Source
broker
Source
close

Shuts down the live reload hub, closing the debouncer and client connections.

Source
debounce_ms
Source
debouncer
Source
enqueue_change(changed_path : String) : Nil

Enqueues a changed file path to trigger a debounced reload signal.

Source
max_deadline_ms
Source
register_client(client_id : String, stream : IO) : Nil

Registers an active SSE client stream.

Source
running?

Checks whether the live reload hub is running.

Source
subscribe(stream : IO, id : String = UUID.v4.to_s) : String

Subscribes an SSE client stream with an auto-generated or explicit identifier.

Source
trigger_reload

Manually triggers a reload event coalesced through debounce window.

Source
unregister_client(client_id : String) : Nil

Unregisters an SSE client stream upon disconnection.

Source