Skip to content
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

[feature]: createEventHook: new function #496

Closed
wheatjs opened this issue May 11, 2021 · 2 comments
Closed

[feature]: createEventHook: new function #496

wheatjs opened this issue May 11, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@wheatjs
Copy link
Member

wheatjs commented May 11, 2021

Was thinking perhaps we could introduce something like useEventHook. This would allow use to do something like what I mentioned in #494.

const { onSourceError } = useMediaControls()

onSourceError((e) => {
  console.log(e)
})

Perhaps there is already a way to do this in VueUse? If so then we can close this.

If not, there is in implementation in the vue-apollo library that looks like it would be a good stating point https://github.com/vuejs/vue-apollo/blob/v4/packages/vue-apollo-composable/src/util/useEventHook.ts

@antfu
Copy link
Member

antfu commented May 11, 2021

Sounds good! I want this for a while as well, but didn't got time to do that. I like your API style which matches with Vue's lifecyle hooks. But for the name, I'd prefer name it createEventHook as it returns functions instead of reactive states. WDYT?

@wheatjs
Copy link
Member Author

wheatjs commented May 11, 2021

createEventHook sounds good to me. Will start a PR soon

@wheatjs wheatjs changed the title [feature]: useEventHook: new function [feature]: createEventHook: new function May 11, 2021
@wheatjs wheatjs added the enhancement New feature or request label May 12, 2021
@wheatjs wheatjs closed this as completed May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants