Module

Network.EventSource

Package
purescript-server-sent-events
Repository
MichaelXavier/purescript-server-sent-events

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

Not all browsers support this API. See Browser Compatibility.

Specification

#addEventListener Source

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

Inherited from EventTarget. EventType corresponds to the

#removeEventListener Source

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

Inherited from EventTarget. EventType corresponds to the

#dispatchEvent Source

dispatchEvent :: Event -> EventSource -> Effect Boolean

Inherited from EventTarget. EventType corresponds to the

#setOnError Source

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

Destructively overwrites the onerror callback for the EventSource

#setOnMessage Source

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

Destructively overwrites the onmessage callback for the EventSource

#setOnOpen Source

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

Destructively overwrites the onopen callback for the EventSource

#eventData Source

eventData :: Event -> String

Get the data from the event.

#readyState Source

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 Source

withCredentials :: EventSource -> Boolean

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

#close Source

close :: EventSource -> Effect Unit

Close the event source connection.

#EventSourceConfig Source

type EventSourceConfig = { withCredentials :: Boolean }

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

#EventSource Source

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 Source

newtype URL

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

Constructors

Instances

#ReadyState Source

data ReadyState

Represents the state of the connection.

Constructors

Instances