Web APIs
EventSource.prototype.close()
Aborts the connection and sets readyState to CLOSED, preventing reconnection by that instance.
Formal Syntax & Structure
javascript syntaxjavascript
source.close()Return Value
undefined
Aborts the connection and sets readyState to CLOSED, preventing reconnection by that instance.
Working Example
Example Snippetjavascript
(async () => {const es=new EventSource("/events");es.close();console.log(es.readyState===EventSource.CLOSED);})()