NetanelBasal
10/27/2016 - 3:21 PM

em4.js

subscribe(eventName, fn) {
  if(!this.events[eventName]) {
    this.events[eventName] = [];
  }
    
  this.events[eventName].push(fn);
  
  return () => {
    this.events[eventName] = this.events[eventName].filter(eventFn => fn !== eventFn);
  }
}