Module

Network.EventSource

An interface to the Server-Sent Events API (SSE).

Not all browsers support this API. See Browser Compatibility.

Specification

#addEventListener

addEventListener :: EventType -> (Event -> Effect Unit) -> Boolean -> EventSource -> Effect Unit

Inherited from EventTarget. EventType corresponds to the

#removeEventListener

removeEventListener :: EventType -> (Event -> Effect Unit) -> Boolean -> EventSource -> Effect Unit

Inherited from EventTarget. EventType corresponds to the

#dispatchEvent

dispatchEvent :: Event -> EventSource -> Effect Boolean

Inherited from EventTarget. EventType corresponds to the

#setOnError

setOnError :: EventSource -> (Event -> Effect Unit) -> Effect Unit

Destructively overwrites the onerror callback for the EventSource

#setOnMessage

setOnMessage :: EventSource -> (Event -> Effect Unit) -> Effect Unit

Destructively overwrites the onmessage callback for the EventSource

#setOnOpen

setOnOpen :: EventSource -> (Event -> Effect Unit) -> Effect Unit

Destructively overwrites the onopen callback for the EventSource

#eventData

eventData :: Event -> String

Get the data from the event.

#readyState

readyState :: EventSource -> Effect ReadyState

The state of the EventSource connection.

CONNECTING The connection has not yet been established, or it was closed and the user agent is reconnecting.

OPEN The user agent has an open connection and is dispatching as it receives them.

CLOSED The connection is not open, and the user agent is not trying to reconnect. Either there was a fatal error or the close() method was invoked.

#withCredentials

withCredentials :: EventSource -> Boolean

Indicate whether the EventSource object was instantiated with CORS credentials set.

#url

#close

close :: EventSource -> Effect Unit

Close the event source connection.

#EventSourceConfig

type EventSourceConfig = { withCredentials :: Boolean }

Indicate if CORS should be set to include credentials. Default: false

#EventSource

newtype EventSource

EventSource class. Inherits from EventTarget It connects to a server over HTTP and receives events in text/event-stream format without closing the connection.

#URL

newtype URL

The URL of the source e.g. "/stream".

Constructors

Instances

#ReadyState

data ReadyState

Represents the state of the connection.

Constructors

Instances

Modules