https://github.com/sonidelav/vue3-instance-events
Vue3 Instance Events Plugin
https://github.com/sonidelav/vue3-instance-events
events instance javascript plugin typescript vue vue3
Last synced: 25 days ago
JSON representation
Vue3 Instance Events Plugin
- Host: GitHub
- URL: https://github.com/sonidelav/vue3-instance-events
- Owner: sonidelav
- License: mit
- Created: 2022-05-27T13:09:34.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-28T10:11:35.000Z (about 4 years ago)
- Last Synced: 2025-03-18T16:58:07.636Z (about 1 year ago)
- Topics: events, instance, javascript, plugin, typescript, vue, vue3
- Language: TypeScript
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Vue3 Instance Events Plugin
Adds `.on` and `.emit` into instance API
## Install
### NPM
```sh
npm install vue3-instance-events
```
Yarn
```sh
yarn add vue3-instance-events
```
## Usage
```js
import { VueInstanceEvents } from 'vue3-instance-events'
import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App).use(VueInstanceEvents)
const instance = app.mount('#app')
instance.on('showed', () => {
...
})
// Event names in camelCase
instance.emit('showComponent')
```
## Vue Documentation
[Breaking Changes v2 to v3 Migrations](https://v3-migration.vuejs.org/breaking-changes/events-api.html#_3-x-update)
> We removed $on, $off and $once methods from the instance completely. $emit is still a part of the existing API as it's used to trigger event handlers declaratively attached by a parent component.