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"