Skip to content

useEventSource | Add autoClose option (as in useWebSocket) #4587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
oxcabe opened this issue Feb 14, 2025 · 0 comments · May be fixed by #4694
Open
4 tasks done

useEventSource | Add autoClose option (as in useWebSocket) #4587

oxcabe opened this issue Feb 14, 2025 · 0 comments · May be fixed by #4694
Labels
enhancement New feature or request has pr

Comments

@oxcabe
Copy link

oxcabe commented Feb 14, 2025

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:

/**
* Automatically close a connection
*
* @default true
*/
autoClose?: boolean

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

@oxcabe oxcabe changed the title useEventSource | Add autoClose option useEventSource | Add autoClose option (as in useWebSocket) Feb 14, 2025
@ilyaliao ilyaliao added the enhancement New feature or request label Feb 14, 2025
@valbertVieira valbertVieira linked a pull request Apr 5, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request has pr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants