How to use EventEmitters

I would like to use EventEmitters to sent events from my main.js file to other pages. For example: When I click on a crosshair on the navbar, a function on main.js is run. That function calls EventEmitters.emit. On the MapPage, I have a EventEmitters.on function, that is listening for “focusMap” event.

Main.js

var EventEmitter = require("FuseJS/EventEmitter");
var myEmitter = new EventEmitter("focusMap");

myEmitter.emit("focusMap");

Map.ux

var EventEmitter = require("FuseJS/EventEmitter");
var myEmitter = new EventEmitter("focusMap");

myEmitter.on("focusMap", function(arg) {
    console.log("focusMap fired with " + arg);
});


This issue is solved. The problem is that I was creating a new emitter on both modules. The solution is to create one emitter, and then share it between the modules with dependency or exporting it with a module.