Module: Observ::MessageEnhancements

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/observ/message_enhancements.rb

Overview

Concern for enhancing Message models with observability and broadcasting support This provides the integration between your Message model and the Observ system

Usage:

class Message < ApplicationRecord
include Observ::MessageEnhancements
end

Instance Method Summary collapse

Instance Method Details

#broadcast_append_chunk(content) ⇒ Object

Broadcast a content chunk to the message Useful for streaming responses



24
25
26
27
28
29
# File 'app/models/concerns/observ/message_enhancements.rb', line 24

def broadcast_append_chunk(content)
  broadcast_append_to "chat_#{chat_id}",
    target: "message_#{id}_content",
    partial: "observ/messages/content",
    locals: { content: content }
end