turbo-ruby
turbo-ruby copied to clipboard
Introduce a `StreamsBuilder` class
Something like:
Turbo::StreamsBuilder.render do |turbo_stream|
turbo_stream.append(...)
turbo_stream.console_log(...)
turbo_stream.morph(...)
end
Which would return one string like:
<turbo-stream action="append" ...>...</turbo-stream>
<turbo-stream action="console_log" ...>...</turbo-stream>
<turbo-stream action="morph" ...>...</turbo-stream>
or inside a model:
class Post < ApplicationRecord
broadcast_turbo_stream_actions do |turbo_stream|
turbo_stream.append(...)
turbo_stream.console_log(...)
turbo_stream.morph(...)
end
end
A POC of this has been implemented https://github.com/marcoroth/turbo_power-rails/pull/18, but in my option it makes more sense to have this class here in turbo-ruby.