Skip to content

Commit d6434ac

Browse files
authored
Fix close event dispatch (#43)
1 parent 9dd7a1d commit d6434ac

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/EventSource.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,15 @@ class EventSource {
262262
}
263263

264264
close() {
265-
this.status = this.CLOSED;
265+
if (this.status !== this.CLOSED) {
266+
this.status = this.CLOSED;
267+
this.dispatch('close', { type: 'close' });
268+
}
269+
266270
clearTimeout(this._pollTimer);
267271
if (this._xhr) {
268272
this._xhr.abort();
269273
}
270-
271-
this.dispatch('close', { type: 'close' });
272274
}
273275
}
274276

0 commit comments

Comments
 (0)