Skip to content

Commit 3100bed

Browse files
update documentation
1 parent cfe5d12 commit 3100bed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/models/concerns/turbo/broadcastable.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@
2626
# and finally prepend the result of that partial rendering to the target identified with the dom id "clearances"
2727
# (which is derived by default from the plural model name of the model, but can be overwritten).
2828
#
29+
# You can also choose to render html or inline erb instead of a partial inside of a broadcast
30+
# you do this by passing an html: option or inline: to any broadcast method that accepts **rendering options
31+
#
32+
# class Message < ApplicationRecord
33+
# belongs_to :user
34+
#
35+
# after_create_commit :update_message_count
36+
#
37+
# private
38+
# def update_message_count
39+
# broadcast_update_to(user, :message_count, html: "<p> #{user.messages.count} </p>")
40+
# end
41+
# end
42+
#
2943
# There are four basic actions you can broadcast: <tt>remove</tt>, <tt>replace</tt>, <tt>append</tt>, and
3044
# <tt>prepend</tt>. As a rule, you should use the <tt>_later</tt> versions of everything except for remove when broadcasting
3145
# within a real-time path, like a controller or model, since all those updates require a rendering step, which can slow down

0 commit comments

Comments
 (0)