# Interface UniversalEventSource

Common EventSource interface that can be implemented by different EventSource-like classes This is compatible with the standard EventSource API but allows for custom implementations

interface UniversalEventSource {
CLOSED: 2;
CONNECTING: 0;
onerror?: ((event: UniversalErrorEvent) => void) | null;
onmessage?: ((event: UniversalMessageEvent) => void) | null;
onopen?: ((event: UniversalEvent) => void) | null;
OPEN: 1;
readyState: 0 | 1 | 2;
url: string;
withCredentials: boolean;
addEventListener(type: string, listener: (event: any) => void): void;
close(): void;
dispatchEvent(event: UniversalEvent): boolean;
removeEventListener(type: string, listener: (event: any) => void): void;
}

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:26

##### Index

### Properties

CLOSED
CONNECTING
onerror?
onmessage?
onopen?
OPEN
readyState
url
withCredentials

### Methods

addEventListener
close
dispatchEvent
removeEventListener

## Properties

### `Readonly` CLOSED

CLOSED: 2

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:30

### `Readonly` CONNECTING

CONNECTING: 0

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:28

### `Optional` onerror

onerror?: ((event: UniversalErrorEvent) => void) | null

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:46

### `Optional` onmessage

onmessage?: ((event: UniversalMessageEvent) => void) | null

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:45

### `Optional` onopen

onopen?: ((event: UniversalEvent) => void) | null

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:44

### `Readonly` OPEN

OPEN: 1

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:29

### `Readonly` readyState

readyState: 0 | 1 | 2

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:33

### `Readonly` url

url: string

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:34

### `Readonly` withCredentials

withCredentials: boolean

- Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:35

## Methods

### addEventListener

- addEventListener(type: string, listener: (event: any) => void): void

  #### Parameters

  - type: string
  - listener: (event: any) => void

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:39

### close

- close(): void

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:38

### dispatchEvent

- dispatchEvent(event: UniversalEvent): boolean

  #### Parameters

  - event: UniversalEvent

  #### Returns boolean

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:41

### removeEventListener

- removeEventListener(type: string, listener: (event: any) => void): void

  #### Parameters

  - type: string
  - listener: (event: any) => void

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/eventsource-interface.ts:40