Closed Alexey1100 closed 1 week ago
This is the quick solution I'm using currently, overriding the Turbo::Streams::ActionBroadcastJob
job, as pointed by dhh in https://github.com/hotwired/turbo-rails/issues/190
class Turbo::Streams::ActionBroadcastJob < ApplicationJob
def perform(stream, action:, target:, **rendering)
rendering[:locals]&.transform_values! do |v|
v.decorate
rescue Draper::UninferrableDecoratorError, NoMethodError
v
end
Turbo::StreamsChannel.broadcast_action_to stream, action: action, target: target, **rendering
end
end
Looking for a good practice when using decorated objects inside templates broadcasted with Turbo::Broadcastable.
Since the rendering happens in
Turbo::Streams::ActionBroadcastJob
, the objects are getting serialised (#817) and the decoration is lost.