# `Mead.Provider.ServerSentEvents`
[🔗](https://github.com/albertosca/mead/blob/main/lib/mead/provider/server_sent_events.ex#L1)

An incremental parser for `text/event-stream` bodies.

`feed/2` takes the bytes as they arrive, split anywhere, and returns the events that became
complete with them. A line ends with `\n`, `\r\n` or `\r`; an event ends with an empty line, so
an event whose terminator has not arrived yet stays buffered and is never emitted half-built.
Comment lines (starting with `:`) are dropped, several `data:` lines of one event are joined with
a newline, and an event with no `data:` line is dropped.

# `event`

```elixir
@type event() :: %{event: String.t() | nil, data: String.t()}
```

# `t`

```elixir
@type t() :: %Mead.Provider.ServerSentEvents{
  buffer: binary(),
  data: [String.t()],
  event: String.t() | nil
}
```

# `feed`

```elixir
@spec feed(t(), binary()) :: {[event()], t()}
```

# `new`

```elixir
@spec new() :: t()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
