Subscribe on changes!

Detect if parent component is listening to a specific event with `@my-event`

avatar
Jun 9th 2021

What problem does this feature solve?

I have a component that is dismissable and I just want to show the X [close] button if there is a function assigned to the component. attrs['onDismiss'] is undifined when I try to access it one I specify emits: ['dismiss'] if I remove the emits then it works and as far as I understand the emits its best practice. I dont want to introduce anoter property since the @dismiss is there and I just want to know if it is assigned.

What does the proposed API look like?

attrs['event'] should return true or false if assigned.

avatar
Jun 11th 2021

You can declare a prop named onEvent to detect an attached event @event on props.onEvent (example)

avatar
Jun 12th 2021

I haven't tried this but I assume this works. Why haven't I tried it? I switched to Blazor :-P

  • Update I was curious and just want to confirm that this works!