Skip to content

Event

Server-Sent Event item yielded by Response.events().

Fields

type

The event type. When the stream omits event:, or provides an empty event: field, this defaults to "message".

Type: str

data

The event payload text. Multiple data: lines are joined with \n.

Type: str

id

The event identifier, if present.

Type: str or nil

retry

The reconnection delay hint from the stream, if present.

Type: int or nil

get https://api.example.com/stream do |response|
  for event = response.events()
    echo "[$event.type] $event.data"