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

#EventSource Source

newtype EventSource

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

#EventSourceConfig Source

type EventSourceConfig = { withCredentials :: Boolean }

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

#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

#readyState Source

readyState :: EventSource -> 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.

#newEventSource Source

newEventSource :: forall eff. URL -> Maybe EventSourceConfig -> Eff (dom :: DOM | eff) EventSource

#setOnError Source

setOnError :: forall eff. EventSource -> (Event -> Eff (dom :: DOM | eff) Unit) -> Eff (dom :: DOM | eff) Unit

Destructively overwrites the onerror callback for the EventSource

#setOnMessage Source

setOnMessage :: forall eff. EventSource -> (Event -> Eff (dom :: DOM | eff) Unit) -> Eff (dom :: DOM | eff) Unit

Destructively overwrites the onmessage callback for the EventSource

#setOnOpen Source

setOnOpen :: forall eff. EventSource -> (Event -> Eff (dom :: DOM | eff) Unit) -> Eff (dom :: DOM | eff) Unit

Destructively overwrites the onopen callback for the EventSource

#addEventListener Source

addEventListener :: forall eff. EventType -> (Event -> Eff (dom :: DOM | eff) Unit) -> Boolean -> EventSource -> Eff (dom :: DOM | eff) Unit

Inherited from EventTarget. EventType corresponds to the

#removeEventListener Source

removeEventListener :: forall eff. EventType -> (Event -> Eff (dom :: DOM | eff) Unit) -> Boolean -> EventSource -> Eff (dom :: DOM | eff) Unit

Inherited from EventTarget. EventType corresponds to the

#dispatchEvent Source

dispatchEvent :: forall eff. Event -> EventSource -> Eff (dom :: DOM, err :: EXCEPTION | eff) Boolean

Inherited from EventTarget. EventType corresponds to the

#eventData Source

eventData :: Event -> String

Get the data from the event.

#close Source

close :: forall eff. EventSource -> Eff (dom :: DOM | eff) Unit

Close the event source connection.