-2๐
I came up with this solution.
if (emit.listener.addToCart && props.product.id === data.id) {
emit('onBeforeAdd')
} else if (emit.listener.changeQuantity && props.product.id === data.id) {
emit('onBeforeAdd')
} else {
emit.listener.setModal({ name: 'modal', id: props.product.id })
}
As you can see, you can handle the cases in a separate ways, not only by the event name, but also by conditions.
Source:stackexchange.com