# vue-simple-events

> Yet another event management plugin, but WITHOUT Vue instance

Latest version **1.1.2** (published 2018-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-simple-events
pnpm add vue-simple-events
yarn add vue-simple-events
bun add vue-simple-events
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-03-25 |
| First published | 2018-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Author | kaskar2008 |
| Maintainers | kaskar2008 |
| Keywords | Vue, Events, Simple, Light, Plugin |

## Links

- npm: https://www.npmjs.com/package/vue-simple-events
- Repository: https://github.com/kaskar2008/vue-simple-events
- Homepage: https://github.com/kaskar2008/vue-simple-events#readme
- Issues: https://github.com/kaskar2008/vue-simple-events/issues
- npm.io page: https://npm.io/package/vue-simple-events

## Dependencies (2)

- [vue](https://npm.io/package/vue.md) ^2.5.16
- [js-simple-events](https://npm.io/package/js-simple-events.md) ^1.0.0

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.1.2 (latest) — 2018-03-25
- 1.1.1 — 2018-03-25
- 1.1.0 — 2018-03-25
- 1.0.3 — 2018-03-25
- 1.0.2 — 2018-03-25
- 1.0.1 — 2018-03-25
- 1.0.0 — 2018-03-25

## README

# vue-simple-events
Yet another event management plugin, but WITHOUT Vue instance

## About

This is just a simple wrapper around [js-simple-events](https://github.com/kaskar2008/js-simple-events) that helps to manage events in a simple way without creating a Vue instance. It also supports TypeScript!

And it's really light - ~1kb in size!

## Methods

Method   | Params            | Description
-------- | ----------------- | ----------------------------------------------------------------
`vm.$events.emit`   | `event, payload`  | Emit the event with the given payload.
`vm.$events.$emit`  | `event, payload`  | _Alias for `emit`_
`vm.$events.fire`   | `event, payload`  | _Alias for `emit`_
`vm.$events.on`     | `event, callback` | Listen for the event with the given callback.
`vm.$events.$on`    | `event, callback` | _Alias for `on`_
`vm.$events.listen` | `event, callback` | _Alias for `on`_
`vm.$events.once`   | `event, callback` | Listen for the event once, after handling - remove the listener.
`vm.$events.$once`  | `event, callback` | _Alias for `$once`_
`vm.$events.off`    | `event, callback` | Remove event listener(s) for the event.
`vm.$events.$off`   | `event, callback` | _Alias for `off`_
`vm.$events.remove` | `event, callback` | _Alias for `off`_

## Examples

```js
// Import and initialize
import Vue from 'vue'
import EventManager from 'vue-simple-events'

Vue.use(EventManager)
```

```js
/// Component 1

methods: {
  eventHandler(payload) {
    console.log('Yay, events work!', payload);
  }
},
created() {
  this.$events.on('test', this.eventHandler);
  this.$events.once('test', () => console.log('This will be called just once!'));
},
beforeDestroy() {
  this.$events.off('test', this.eventHandler);
}
```

```js
/// Component 2

created() {
  // Emit events
  this.$events.emit('test', 'Hello!');
  // Logs:
  // -> Yay, events work! Hello!
  // -> This will be called just once!

  this.$events.emit('test', 'Hello!');
  // Logs:
  // -> Yay, events work! Hello!
  // (The 'once' handler isn't fired)
}
```

## Demo
[webpack 4 application](https://github.com/Raiondesu/webpack-vue-ts)

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