class EStream::Generic::Evented

Public Instance Methods

<<(data)
Alias for: data
data(data) click to toggle source

sending data

@example

event_stream :keep_open do |out|
  out.data 'chunk one'
  out.data 'chunk two'
  out.data 'etc.'
end
# File lib/e-core/instance/stream.rb, line 142
def data data
  # - any single message should not contain \n except at the end.
  # - EventSource expects \n\n at the end of each single message.
  write "data: %s\n\n" % data.gsub(/\n|\r/, '')
end
Also aliased as: <<
write(data) click to toggle source
# File lib/e-core/instance/stream.rb, line 149
def write data
  @scheduler.schedule { @front.call(data.to_s) }
end