Skip to content

Instantly share code, notes, and snippets.

@arvidkahl
Created February 11, 2017 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvidkahl/fd59d57956ea87342fa58468310e242f to your computer and use it in GitHub Desktop.
Save arvidkahl/fd59d57956ea87342fa58468310e242f to your computer and use it in GitHub Desktop.
components-eventbus.js
// Two isolated components accessing the same global
let ComponentA = Vue.extend({
  created: function(){
  EventBus.$on(“thatEvent”, ()=>{
  console.log(“Event received”);
  })
  }
});
let ComponentB = Vue.extend({
  created: function(){
  EventBus.$emit(“thatEvent”);
  console.log(“Event emitted.”)
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment