title: es6 javascript class with pub sub pattern, losing context
body: <p>i'm kinda new to es6 features, i'm trying to implement some basic class, like this</p>
  
  <pre><code>class App {
    constructor() {
      this.init();
    }
  
    init() {
      console.log("init!");
      this.hello();
    }
  
    hello(){
      console.log("Hello!");
    }
  }
  
  let app = new App;
  </code></pre>
  
  <p>everything works fine. this is my output:</p>
  
  <pre><code>init
  Hello!
  </code></pre>
  
  <p>then i tried to implement the same thing with publish / subscribe pattern (using <a href="https://www.npmjs.com/package/pubsub-js" rel="nofollow noreferrer">PubSubJs</a> plugin):</p>
  
  <pre><code>class App {
    constructor() {
      PubSub.subscribe('say hello', this.init);
    }
  
    init() {
      console.log("init!");
      this.hello();
    }
  
    hello(){
      console.log("Hello!");
    }
  }
  
  let app = new App;
  
  PubSub.publish('say hello');
  </code></pre>
  
  <p>This will call correctly the <code>init</code> method, but then will lose the class context when trying to call <code>this.hello()</code> </p>
  
  <p>infact i get this output:</p>
  
  <pre><code>init //correct
  Uncaught TypeError: this.hello is not a function //&lt;- why this?
  </code></pre>
  
  <p><a href="https://codepen.io/anon/pen/EpYmrQ?editors=0012" rel="nofollow noreferrer">DEMO HERE</a></p>
  
  <p>any idea? am i missing something? thanks</p>