var EventEmitter = require('events').EventEmitter;

class ActionCreator extends EventEmitter {
  constructor(api){
    super();
    this.api = api;
  }

  subscribe(actionName, callback) {
    this.on(actionName, callback);
  }

  unsubscribe(actionName, callback) {
    this.removeListener(actionName, callback);
  }

  initialize() {
    var data = this.api.getCategoriesAndArticles();
    this.emit('initialize', data)
  }

  filterByIntensity(intensity) {
    this.emit('filterByIntensity', intensity);
  }
};

module.exports = ActionCreator;

var Dispatcher = require('./flux/dispatcher.js');

class ActionCreator {
  constructor(api){
    this.api = api;
  }

  initialize() {
    var data = this.api.getCategoriesAndArticles();
    dispatcher.dispatch({
      action: 'initialize',
      data: data
    });
  }

  filterByIntensity(intensity) {
    dispatcher.dispatch({
      action: 'filterByIntensity',
      intensity: intensity
    });
  }
};

module.exports = ActionCreator;

Use dispatcher instead of extending EventEmitter.
Refactor: Use dispatcher instead of extending EventEmitter.
