Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

EventSource

interface EventSource extends EventTarget {
readonly CLOSED: number;
readonly CONNECTING: number;
onerror: ((this: EventSource, ev: Event) => any) | null;
onmessage: ((this: EventSource, ev: MessageEvent) => any) | null;
onopen: ((this: EventSource, ev: Event) => any) | null;
readonly OPEN: number;
readonly readyState: number;
readonly url: string;
readonly withCredentials: boolean;
addEventListener<K extends keyof EventSourceEventMap>(
type: K,
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: (this: EventSource, event: MessageEvent) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void;
close(): void;
removeEventListener<K extends keyof EventSourceEventMap>(
type: K,
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: (this: EventSource, event: MessageEvent) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void;
}
var EventSource: {
prototype: EventSource;
readonly CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
}
;

§Extends

§Properties

§
readonly CLOSED: number
[src]
§
readonly CONNECTING: number
[src]
§
onerror: ((this: EventSource, ev: Event) => any) | null
[src]
§
onmessage: ((this: EventSource, ev: MessageEvent) => any) | null
[src]
§
onopen: ((this: EventSource, ev: Event) => any) | null
[src]
§
readonly OPEN: number
[src]
§
readonly readyState: number
[src]

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

§
readonly url: string
[src]

Returns the URL providing the event stream.

§
readonly withCredentials: boolean
[src]

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

§Methods

§
addEventListener<K extends keyof EventSourceEventMap>(
type: K,
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
addEventListener(
type: string,
listener: (this: EventSource, event: MessageEvent) => any,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
close(): void
[src]

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

§
removeEventListener<K extends keyof EventSourceEventMap>(
type: K,
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
[src]
§
removeEventListener(
type: string,
listener: (this: EventSource, event: MessageEvent) => any,
options?: boolean | EventListenerOptions,
): void
[src]
§
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void
[src]