HTTP.EventSource (http_event_source v0.10.0)

View Source

Browser-like EventSource client API for Elixir.

Events are delivered as messages to the owner process:

{HTTP.EventSource, source, %HTTP.EventSource.Event.Open{}}
{HTTP.EventSource, source, %HTTP.EventSource.Event.Message{}}
{HTTP.EventSource, source, %HTTP.EventSource.Event.Error{}}

Custom server-sent event names are delivered through the message event's type field.

Summary

Types

t()

@type t() :: %HTTP.EventSource{
  pid: pid() | nil,
  ref: reference() | nil,
  url: String.t() | nil,
  with_credentials: boolean()
}

Functions

close(source)

@spec close(t()) :: :ok

closed()

@spec closed() :: 2

connecting()

@spec connecting() :: 0

last_event_id(source)

@spec last_event_id(t()) :: String.t()

new(url, init \\ [])

@spec new(String.t() | URI.t(), keyword() | map()) :: t() | {:error, term()}

open()

@spec open() :: 1

ready_state(source)

@spec ready_state(t()) :: 0 | 1 | 2

reconnect_time(source)

@spec reconnect_time(t()) :: non_neg_integer()

url(event_source)

@spec url(t()) :: String.t() | nil

with_credentials(event_source)

@spec with_credentials(t()) :: boolean()