# @carbdrox/vue-event-bus

> A Vue.Js plugin which adds a global event bus to your project.

Latest version **1.0.1** (published 2021-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @carbdrox/vue-event-bus
pnpm add @carbdrox/vue-event-bus
yarn add @carbdrox/vue-event-bus
bun add @carbdrox/vue-event-bus
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-02-20 |
| First published | 2021-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Christian Förster |
| Maintainers | carbdrox |
| Keywords | Vue, plugin, events, eventbus, event-bus, bus |

## Links

- npm: https://www.npmjs.com/package/@carbdrox/vue-event-bus
- Repository: https://github.com/Carbdrox/vue-event-bus
- Homepage: https://github.com/Carbdrox/vue-event-bus#readme
- Issues: https://github.com/Carbdrox/vue-event-bus/issues
- npm.io page: https://npm.io/package/@carbdrox/vue-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

- 1.0.1 (latest) — 2021-02-20
- 1.0.0 — 2021-02-19

## README

# Vue.Js Event-Bus
A Vue.Js plugin which adds a global event bus to your vue-project.

## Installation

### Using npm

```
npm i @carbdrox/vue-event-bus --save
```

## Setup
Normally done inside `main.js`
```javascript
import VueEventBus from "@carbdrox/vue-event-bus";

Vue.use(VueEventBus);
```

## Usage
Inside your Components e.g. `App.vue`
```javascript
export default {
    created() {
        this.$addListener('event', () => {
            console.log('event Fired!')
        });
    },
    methods: {
        fireEvent() {
            this.$emitEvent('event');
        }
    }
}
```

### Interface
This Plugin provides the following interface   
`this.$addListener(eventName, listener, amount)`:  

| Parameter | Required | Description                                                                     |
|-----------|----------|---------------------------------------------------------------------------------|
| eventName | yes      | The name of the event to listen for.                                            |
| listener  | yes      | The function that will be executed when the event is fired.                     |
| amount    | no       | The number of times the listener should be executed. (empty or -1 for no limit) |

`this.$removeListener(eventName, listener)`:  

| Parameter | Required | Description                                                                                                                |
|-----------|----------|----------------------------------------------------------------------------------------------------------------------------|
| eventName | no       | The name of the event to remove. If no eventName specified, all events will be deleted                                     |
| listener  | no       | The function of the event to be deleted. If no function is specified, all functions of the specified event will be deleted |

`this.$emitEvent(eventName, params)`:  

| Parameter | Required | Description                                                                                                  |
|-----------|----------|--------------------------------------------------------------------------------------------------------------|
| eventName | yes      | The name of the event to be fired.                                                                           |
| params    | no       | The parameter to be passed to the event. If multiple parameters are required, they must be passed as object. |

## License

MIT

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