module Rails::SSE

Constants

VERSION

Public Instance Methods

channel() click to toggle source
# File lib/rails/sse.rb, line 6
def channel
  Channel.new(response.stream)
end
stream() { |channel| ... } click to toggle source
# File lib/rails/sse.rb, line 10
def stream
  response.headers['Content-Type'] = 'text/event-stream'

  begin
    yield(channel) if block_given?
  rescue IOError
  ensure
    response.stream.close unless response.stream.closed?
  end
end