vuemit

The smallest Vue.js events handler.
18,053 141
Install
npm install vuemit
Latest Version:2.0.0
Older releases:2
License:MIT
Last Updated:Apr 18, 2023
Links: GitHub  ·  npm
Maintainer: oullin

Vuemit

Vuemit is a tiny library to work with events on Vue.js. Its aim is to keeping simple the fact of sharing information between any number of components.

Installation

npm install vuemit --save

Gettings started

Require the library within your entry point or your bootstrap file.

window.Vuemit = require('vuemit');

Now you will have a global Vuemit variable which you can use anywhere in your app.

Usage

  • all the methods take the same props as the Original Events, except for the events-names which can be an array.
Vue Vuemit Description
this.$emit() Vuemit.fire() Fire an event/s : takes 2 arguments ('event-name', (optional) data object)
this.$on() Vuemit.listen() Listen for an event/s : takes 2 arguments ('event-name', callback)
this.$once() Vuemit.listenOnce() Listen once to an event/s : takes 2 arguments ('event-name', callback)
this.$off() Vuemit.remove() Remove listeners for an event/s: takes 2 arguments ('event-name', callback)
this.$off() Vuemit.removeListenersFrom() Remove listeners from an event/s: takes 1 arguments ('event-name')
this.$off() Vuemit.removeAll() Remove all event listeners: takes no arguments
  • Vue started to support events array from v2.2.0+ except $emit & $once but with Vuemit you can use events-names as an array with all the methods except removeAll() which takes no arguments.
// fire multiple events with a shared payload
Vuemit.fire(['event1','event2'], {some: data})

// listen once to multiple events with a shared callback
Vuemit.listenOnce(['other-event1', 'other-event2'], ()=>{
    // do something ex."refresh localStorage"
})

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

License

The MIT License (MIT). Please see License File for more information.

How can I thank you?

Why not star the github repo? Why not share the link for this repository on Twitter? Spread the word!

Don't forget to follow me on twitter!

Thanks!

Gustavo Ocanto. gustavoocanto@gmail.com

Related Packages

vue-button-spinner

A simple button spinner.

16,948 35
vue-event-handler

Global event bus for Vue 1 and Vue 2.

2,456 15
vue-bus

A event bus for Vue.js

338,089 309
vue-events

Easy event handling for Vue applications.

294,092 231
vue2-simple-calendar

A simple event calendar component

2,776 53

Version History

Version Released License
2.0.0 MIT
1.0.9 MIT
1.0.8 MIT
1.0.7 MIT
1.0.6 MIT
Pre-releases (5)
Version Released License
1.0.2-1 MIT
1.0.1-4 MIT
1.0.1-3 MIT
1.0.1-2 MIT
1.0.1-1 MIT