Skip to content

martinhipp/vue-bubble

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vue-bubble

broadcast and bubble events to spread between Vue component

Vue.prototype.$emit can only receive event in the instance component. It doesn't have mechanism for bubbling and broadcasting. So I write this Vue plugin to extend it.

USAGE

Usage is pretty easy.

import VueBubbles from 'vue-bubbles';
import Vue from 'Vue';

Vue.use(VueBubbles);

// In Your Component

// somemethod

this.$broadcast(SOME_EVENT, { ...payload });
// That will emit a message that the component and its children and chilren's children ... will receive the event.

// when you want to stop spreading you can write this.

this.$on(SOME_EVENT, e => {
    e.stopSpread();
    const data = e.data;
    const originComponent = e.originComponent;
});

this.$bubble(SOME_EVENT, { ...payload });
// That will emit a message that the component and recursively emit the parent. Also you can stop spreading.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 81.4%
  • Vue 15.7%
  • HTML 2.9%