0.3.1 • Published 9 months ago

extra-sse v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

extra-sse

Install

npm install --save extra-sse
# or
yarn add extra-sse

API

interface IEvent {
  comment?: string
  event?: string
  data?: string
  id?: string
  retry?: number
}

stringifyEvent

function stringifyEvent(event: IEvent): IterableIterator<string>

fetchEvents

/**
 * @throws {HTTPClientError}
 * @throws {AbortError}
 */
function fetchEvents(
  input: string | URL | Getter<Request>
, options?: {
    lastEventId?: string

    autoReconnect?: boolean = true
    retry?: number = 0

    /**
     * The handler is called when a connection is properly established.
     * The handler is also called when the connection is re-established.
     */
    onOpen?: () => void
  }
): AsyncIterableIterator<IEvent>