Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a StreamsBuilder class #2

Open
marcoroth opened this issue Jan 8, 2023 · 1 comment
Open

Introduce a StreamsBuilder class #2

marcoroth opened this issue Jan 8, 2023 · 1 comment

Comments

@marcoroth
Copy link
Owner

marcoroth commented Jan 8, 2023

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
@marcoroth
Copy link
Owner Author

A POC of this has been implemented marcoroth/turbo_power-rails#18, but in my option it makes more sense to have this class here in turbo-ruby.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant