-
Notifications
You must be signed in to change notification settings - Fork 545
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
Remove instance event API methods #118
Conversation
This RFC is now in final comments stage. An RFC in final comments stage means that: The core team has reviewed the feedback and reached consensus about the general direction of the RFC and believe that this RFC is a worthwhile addition to the framework. |
@yyx990803 Please update the link to the rendered rfc. |
@bodograumann I have updated. |
Thanks for notifying about mitt. |
Sorry if this is an obvious question, in Vue.js 2 you could extend a component and listen to events that the parent (super) component emitted.
Is there any way to achieve the same now that $on will be removed? |
@kouts I need to know this too 😊 |
I'm a bit confused about this RFC... Not by the proposal to remove the instance methods and I have no objections on using Mitt, however, how would this play with 0030-emits-option as that states the usage of $emit? |
Hello.
Since in Vue 3 $once and $on are deprecated. Do we have an option to migrate this code and keep it in event based way? |
That's a good question, what is the new way to listen lifecycle hooks? Or it is now impossible? Friendly ping @posva / @yyx990803 ❤️ Thanks! |
@Kocal it's not documented but all lifecycle hooks receive component's instance as the second argument (source code) + there's import { onMounted, onBeforeUnmount, getCurrentInstance, ref } from 'vue'
export default {
name: 'Component',
setup() {
const instance = getCurrentInstance()
const elRef = ref(null)
onMounted(() => {
const picker = new Pickaday(elRef.value, {});
onBeforeUnmount(() => {
picker.destroy()
}, instance)
})
}
} |
Alright, thank you! |
Summary
Remove
$on
,$off
and$once
instance methods. Vue instances no longer implement the event emitter interface.Rendered