Response AND/OR broadcast?

Hello All :wave:

I have a controller that evolved from just responding with turbo streams to now also broadcasting streams (so other page viewers can see changes)

I wonder what is considered the best way to respond now I have a controller that updates the UI in 2 ways :thinking:
Should I respond with only a status code and rely on the broadcast to handle the UI updates… or is there value in responding via turbostream as well as broadcasting?

thanks for any info you can provide :slight_smile:

sample controller to help illustrate what I am talkin about:

  class EntryController < ApplicationController
    def create
      result = AddNew.call(entry_params)
      if result.success?
        component_html = EntryComponent.new(entry: result.entry).render_in(view_context)

        # added line to broadcast here:
        Turbo::StreamsChannel.broadcast_append_to(:entries, target: result.form.entry_slot, html: html)

        # ..should I turbo_stream or just send as possitive status code?
        render turbo_stream: [
          turbo_stream.append(result.form.entry_slot, html: component_html)
        ]
      else
        render(:new, locals: {form: result.form})
      end
    end
  end