Class: ViewComponentReducible::Runtime
- Inherits:
-
Object
- Object
- ViewComponentReducible::Runtime
- Defined in:
- lib/view_component_reducible/runtime.rb
Overview
Core runtime for dispatching messages and rendering components.
Constant Summary collapse
- MAX_EFFECT_STEPS =
8
Instance Method Summary collapse
-
#call(envelope:, msg:, target_path:, controller:) ⇒ Array<Hash, String>
[new_envelope, html].
-
#render_target(envelope:, target_path:, controller:) ⇒ String
Render HTML for a specific path after state updates.
Instance Method Details
#call(envelope:, msg:, target_path:, controller:) ⇒ Array<Hash, String>
Returns [new_envelope, html].
13 14 15 16 17 18 19 20 |
# File 'lib/view_component_reducible/runtime.rb', line 13 def call(envelope:, msg:, target_path:, controller:) root_klass = ViewComponentReducible.registry.fetch(envelope['root']) new_env = deep_dup(envelope) new_env = dispatch_to_path(root_klass, new_env, msg, target_path, controller) html = render_root(root_klass, new_env, controller) [new_env, html] end |
#render_target(envelope:, target_path:, controller:) ⇒ String
Render HTML for a specific path after state updates.
27 28 29 30 31 |
# File 'lib/view_component_reducible/runtime.rb', line 27 def render_target(envelope:, target_path:, controller:) root_klass = ViewComponentReducible.registry.fetch(envelope['root']) component_klass, env = find_env_and_class(root_klass, envelope, target_path) controller.view_context.render(component_klass.new(vcr_envelope: env)) end |