-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Labels
Description
Clear and concise description of the problem
Provide an autoClose
option that closes the EventSource
automatically on a beforeunload
window event trigger. Same thing useWebSocket
provides:
vueuse/packages/core/useWebSocket/index.ts
Lines 93 to 98 in 77c795d
/** | |
* Automatically close a connection | |
* | |
* @default true | |
*/ | |
autoClose?: boolean |
vueuse/packages/core/useWebSocket/index.ts
Lines 318 to 322 in 77c795d
if (autoClose) { | |
if (isClient) | |
useEventListener('beforeunload', () => close(), { passive: true }) | |
tryOnScopeDispose(close) | |
} |
Suggested solution
Same implementation as in useWebSocket
.
Alternative
N/A
Additional context
https://vueuse.org/core/useEventSource/
https://vueuse.org/core/useWebSocket/
https://vueuse.org/core/useWebSocket/#autoclose
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
OrbisK