# vue-plugin-event-bus

> vue2.x eventbus plugin

Latest version **0.0.5** (published 2020-11-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-plugin-event-bus
pnpm add vue-plugin-event-bus
yarn add vue-plugin-event-bus
bun add vue-plugin-event-bus
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2020-11-17 |
| First published | 2020-06-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | shooterRao |
| Maintainers | raojw |
| Keywords | vue, vue-plugin, eventBus |

## Links

- npm: https://www.npmjs.com/package/vue-plugin-event-bus
- Repository: https://github.com/shooterRao/vue-plugin-event-bus
- Homepage: https://github.com/shooterRao/vue-plugin-event-bus#readme
- Issues: https://github.com/shooterRao/vue-plugin-event-bus/issues
- npm.io page: https://npm.io/package/vue-plugin-event-bus

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.0.5 (latest) — 2020-11-17
- 0.0.4 — 2020-11-15
- 0.0.3 — 2020-09-22
- 0.0.2 — 2020-09-22
- 0.0.1 — 2020-06-12

## README

# vue-plugin-event-bus

Lightweight eventBus solution, easy to use eventBus in vue2.x

## Feature

- Mapping relationship between events and components
- Auto $off events

## Installing

use npm

```
npm install vue-plugin-event-bus
```

use yarn

```
yarn add vue-plugin-event-bus
```

## Usage

```js
import Vue from "vue";
import VueEventBus from "vue-plugin-event-bus"; 

Vue.use(VueEventBus);

// now you can use $eventBus directly in a vue component
// in vue component lifecycle hooks...
{
  created() {
    this.$eventBus.on('xxx', function callback() {}, this); // you should pass in the current vue instance
    // if you don't pass the current instance,like use this.$on(xxx),you should manual remove eventHandler...
    // so,I strongly recommend you pass 'this'(current vue instance)
    // because it can auto remove eventHandler when component is destroyed
  }
}

// in another vue component
{
  methods: {
    test() {
      this.$eventBus.emit('xxx', ...);
    }
  },
}
```

---
_Source: https://npm.io/package/vue-plugin-event-bus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
