Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fffixed/vue-bus
Tiny simple central event bus plugin for Vue.js
https://github.com/fffixed/vue-bus
events vue-plugin vuejs
Last synced: 26 days ago
JSON representation
Tiny simple central event bus plugin for Vue.js
- Host: GitHub
- URL: https://github.com/fffixed/vue-bus
- Owner: fffixed
- License: mit
- Created: 2017-07-29T07:31:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T08:44:21.000Z (over 6 years ago)
- Last Synced: 2024-01-08T08:50:18.057Z (5 months ago)
- Topics: events, vue-plugin, vuejs
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 50
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
- awesome-vue. - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
- awesome-stars - fffixed/vue-bus - Tiny simple central event bus plugin for Vue.js (JavaScript)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
- awesome-vue - vue-bus ★42 - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
- awesome-vue - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Components & Libraries / Utilities)
- awesome-vuejs - vue-bus - Tiny simple central event bus plugin for Vue.js 2. (Utilities / Custom Events)
README
# vue-bus
[![awesome-vue](https://img.shields.io/badge/Vue.js-AWESOME-ff69b4.svg)](//github.com/vuejs/awesome-vue)
[![license](https://img.shields.io/github/license/fffixed/vue-bus.svg)](//opensource.org/licenses/MIT)A tiny simple central event bus plugin for [Vue.js](//vuejs.org) (requires Vue >= 2.0).
The plugin realise [Non Parent-Child Communication](//vuejs.org/v2/guide/components.html#Non-Parent-Child-Communication).
_(655 byte gzip)_
## Installation
Download and use with your build system
```javascript
import VueBus from 'vue-bus'
// ... maybe ...
var VueBus = require('vue-bus')// ... and ...
Vue.use(VueBus)
```
Or just include it with a script tag
```html```
:sparkles:## Usage
direct way:
```javascript
// in component A's method
this.$bus.$emit('my-event', 1)// in component B's created hook
this.$bus.$on('my-event', function(arg) {
// ...
})//And don't forget to use "this.$bus.$off" to remove unnecessary listeners.
```magic way:
```javascript
// in component A's method
this.$bus=['my-event', 1]// in component B create $bus option
methods: { /* ... */ },
$bus: {
'my-event': function(arg) {
// ...
}
}
```## License
[MIT](//opensource.org/licenses/MIT)Copyright (c) 2017 fffixed