You can specify which partials to render. For example, after the cart model is updated a replacement is broadcasted to the badge_id and another one to cart. Each renders a unique partial.
class Cart
...
after_update_commit do
broadcast_replace_to 'badge',
partial: 'carts/badge',
locals: { cart: self },
target: "badge_#{id}"
end
after_update_commit do
broadcast_replace_to 'cart',
partial: 'carts/active_cart',
locals: { cart: self }
end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…