EventSource - Web documentation
interface EventSource
extends EventTarget

Properties

onerror: ((
ev: Event,
) => any) | null
onmessage: (() => any) | null
onopen: ((
ev: Event,
) => any) | null
readonly
readyState: number

Returns the state of this EventSource object's connection. It can have the values described below.

readonly
url: string

Returns the URL providing the event stream.

readonly
withCredentials: boolean

Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.

readonly
CONNECTING: 0
readonly
OPEN: 1
readonly
CLOSED: 2

Methods

close(): void

Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.

addEventListener<K extends keyof EventSourceEventMap>(
type: K,
listener: () => any,
options?: boolean | AddEventListenerOptions,
): void
addEventListener(
type: string,
listener: () => any,
options?: boolean | AddEventListenerOptions,
): void
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
removeEventListener<K extends keyof EventSourceEventMap>(
type: K,
listener: () => any,
options?: boolean | EventListenerOptions,
): void
removeEventListener(
type: string,
listener: () => any,
options?: boolean | EventListenerOptions,
): void
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void