Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ const options: EventSourceOptions = {
body: undefined, // Your request body sent on connection. Default: undefined
debug: false, // Show console.debug messages for debugging purpose. Default: false
pollingInterval: 5000, // Time (ms) between reconnections. If set to 0, reconnections will be disabled. Default: 5000
lineEndingCharacter: null // Character(s) used to represent line endings in received data. Common values: '\n' for LF (Unix/Linux), '\r\n' for CRLF (Windows), '\r' for CR (older Mac). Default: null (Automatically detect from event)
lineEndingCharacter: null, // Character(s) used to represent line endings in received data. Common values: '\n' for LF (Unix/Linux), '\r\n' for CRLF (Windows), '\r' for CR (older Mac). Default: null (Automatically detect from event)
lastEventId: null // `Last-Event-ID` request header sent on initial connection. Default null.
}
```

Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface EventSourceOptions {
debug?: boolean;
pollingInterval?: number;
lineEndingCharacter?: string;
lastEventId?: string;
}

type BuiltInEventMap = {
Expand Down
2 changes: 1 addition & 1 deletion src/EventSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class EventSource {
CR = '\r';

constructor(url, options = {}) {
this.lastEventId = null;
this.status = this.CONNECTING;

this.eventHandlers = {
Expand All @@ -30,6 +29,7 @@ class EventSource {
this.debug = options.debug || false;
this.interval = options.pollingInterval ?? 5000;
this.lineEndingCharacter = options.lineEndingCharacter || null;
this.lastEventId = options.lastEventId || null;

const defaultHeaders = {
Accept: 'text/event-stream',
Expand Down