Module: Hibiki::Rails

Defined in:
lib/hibiki/rails.rb,
lib/hibiki/rails/engine.rb,
lib/hibiki/rails/channel.rb,
lib/hibiki/rails/helpers.rb,
lib/hibiki/rails/version.rb,
lib/hibiki/rails/debounce.rb,
lib/hibiki/rails/registry.rb,
lib/hibiki/rails/broadcasts.rb,
lib/hibiki/rails/graph_actor.rb,
lib/hibiki/rails/reactive_form.rb,
lib/generators/hibiki/rails/generator_helpers.rb,
lib/generators/hibiki/rails/phlex/phlex_generator.rb,
lib/generators/hibiki/rails/island/island_generator.rb,
lib/generators/hibiki/rails/install/install_generator.rb,
lib/generators/hibiki/rails/stimulus/stimulus_generator.rb

Overview

Rails glue for hibiki: connection-scoped signal graphs over ActionCable, pushing re-rendered HTML through Turbo Streams.

Defined Under Namespace

Modules: Broadcasts, Channel, Generators, Helpers, ReactiveForm Classes: Debounce, Engine, GraphActor, Registry

Constant Summary collapse

VERSION =
"0.3.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.registryObject (readonly)

Process-wide registry of live hibiki channels.



47
48
49
# File 'lib/hibiki/rails/registry.rb', line 47

def registry
  @registry
end

Class Method Details

.default_error_reporterObject

Default per-job error sink for GraphActor: the Rails error reporter, so a raising action shows up wherever the app already sends errors. This is the outer layer of the funnel — a flush error first goes to an app-set Hibiki.error_handler if there is one, and only re-raises into the actor's per-job rescue when there isn't.

It ALSO logs, in local environments only. ActiveSupport::ErrorReporter has no subscribers by default, so report alone means a graph-thread exception vanishes completely in a stock app: no log line, no stack, and the only symptom is a fragment that stops updating. That cost real debugging time while the CRUD reference app was built. local? is development + test, so production apps — which do have a subscriber — get no duplicate line. Swap the whole thing per graph via GraphActor.new(on_error:) if you want different behaviour.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hibiki/rails.rb', line 24

def self.default_error_reporter
  lambda do |error|
    if ::Rails.env.local? && ::Rails.logger
      ::Rails.logger.error(
        "[hibiki_rails] #{error.class}: #{error.message}\n" \
        "#{Array(error.backtrace).first(20).join("\n")}"
      )
    end
    ::Rails.error.report(error, handled: true, source: "hibiki_rails")
  end
end