Skip to content

Instantly share code, notes, and snippets.

@wmcmurray
Created September 23, 2018 14:02
Show Gist options
  • Save wmcmurray/21600a7fdfb8befadb093b4fe8f3e578 to your computer and use it in GitHub Desktop.
Save wmcmurray/21600a7fdfb8befadb093b4fe8f3e578 to your computer and use it in GitHub Desktop.
A simple events bus used to pub/sub global events across unrelated parts of a VueJS app.
import Vue from 'vue'
var MEDIATOR_VUE = new Vue();
var MEDIATOR = {
emit : MEDIATOR_VUE.$emit.bind(MEDIATOR_VUE),
on : MEDIATOR_VUE.$on.bind(MEDIATOR_VUE),
off : MEDIATOR_VUE.$off.bind(MEDIATOR_VUE),
once : MEDIATOR_VUE.$once.bind(MEDIATOR_VUE),
};
export default MEDIATOR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment