Skip to content

Vue eventbus enhancements to support automatic destruction and other many features.

Notifications You must be signed in to change notification settings

xygahs0801/vue-super-eventbus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vue-super-eventbus

An enhanced component of Vue event bus can be automatically destroyed without manual cancellation of subscription events, modularization, immutability of event data and many other features.

Install

npm i --save vue-super-eventbus

Usage

On Vue entry

import EventBus from "vue-super-eventbus"
Vue.use(EventBus)

In Vue component

// Recommend
on:{
  event1(data){
    // handle data
    console.log(data)
  },
  event2(data){
    // handle data
    console.log(data)
  }
},
// Or
created() {
  this.$bus.on(this, "event1", data => {
    // handle data
    console.log(data);
  });
  this.$bus.on(this, "event2", data => {
    // handle data
    console.log(data);
  });
},

In other Vue component

created() {
  this.$bus
    .emit("event1", 'test message')
    .emit("event2", { message: "test json message" });
}
beforeDestroy() {
  // No need to off the event, The lib take care of this for you.
}

About

Vue eventbus enhancements to support automatic destruction and other many features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published