|
@ -13,19 +13,20 @@ class ApplicationController < ActionController::Base |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
class ProxyStream |
|
|
class ProxyStream |
|
|
|
|
|
# see: https://turbo.hotwired.dev/reference/streams |
|
|
|
|
|
STREAM_ACTIONS = %i[append prepend replace update remove before after refresh].freeze |
|
|
|
|
|
STREAM_ACTIONS.each do |method| |
|
|
|
|
|
define_method(method) do |*streamables, **attributes| |
|
|
|
|
|
@elements << @turbo_stream.send(method, *streamables, **attributes) |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
attr_reader :elements |
|
|
attr_reader :elements |
|
|
|
|
|
|
|
|
def initialize(turbo_stream) |
|
|
def initialize(turbo_stream) |
|
|
@turbo_stream = turbo_stream |
|
|
@turbo_stream = turbo_stream |
|
|
@elements = [] |
|
|
@elements = [] |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def append(*streamables, **attributes) |
|
|
|
|
|
@elements << @turbo_stream.append(*streamables, **attributes) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def replace(*streamables, **attributes) |
|
|
|
|
|
@elements << @turbo_stream.replace(*streamables, **attributes) |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
end |
|
|
|
|
|
private_constant(:ProxyStream) |
|
|
end |
|
|
end |