-
Notifications
You must be signed in to change notification settings - Fork 963
feat(useOverlay): add on method to listen emits from component
#5244
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
base: v4
Are you sure you want to change the base?
Conversation
on method to listen emits from component
commit: |
|
I forget the API instance documentation + Caveats section miss a warning about the limitation of the composable. We need to discuss about its limitation is caused by typescript limitations |
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
60e4da6 to
dc8040f
Compare
|
@genu can you take a look? |
|
Thanks for this @edimitchel I think it looks good. The I think it may be even a good idea to deprecate the old way of handling events. Having multiple ways could be confusing. What do you think about that? We could maybe, add a const modal = overlay.create(LazyModalExample, {
props: {
count: count.value,
onClose: (value: number) => {
console.log('Modal closed with value:', value)
}
}
})Otherwise, we could depreciate them in a future version as a breaking change |
|
@edimitchel Let me know if you need some help with this |
β¦`on('emit', callback)`
|
Here we are, I made it (sorry for the delay, I didn't take time for doing this small change). Let me know if you see something wrong. |
genu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates @edimitchel
I left som comments.
A bigger issue that we need to address is the breaking change that we should avoid.
For example, this would not work as expected:
const modal = overlay.create(LazyModalExample, {
props: {
count: count.value
}
})
modal.on('close', () => {
console.log('Modal closed')
})
function openModal() {
count.value++
modal.open({ count: count.value })
}The on callback fires, but the modal doesn't close. See my explanation on the vercel comment above.
β¦+ add warnings on patch/open method
|
I'm not sure it's good now but I'm now not very confident with this feature because of TypeScript limitation which will make the |
π Linked issue
Resolved #5233
β Type of change
π Description
Introducing this new
onmethod permits to easy bind emits event before opening for let developer to only think about props in create/open/patch methods.π Checklist