title: Own pubsub implementation vs using addEventListener() + CustomEvent?
body: <p>Is there a bigger difference between a self made pubsub system and what <code>addEventListener()</code> plus using <code>new CustomEvent</code>?</p>
  
  <p>Pseudocode implementation of pubsub (<a href="https://davidwalsh.name/pubsub-javascript" rel="noreferrer">taken from here</a>): </p>
  
  <pre><code>// Publishing to a topic:
  events.publish('/page/load', {
      url: '/some/url/path' // any argument
  });
  // ...and subscribing to said topic in order to be notified of events:
  
  var subscription = events.subscribe('/page/load', function(obj) {
      // Do something now that the event has occurred
  });
  
  // ...sometime later where I no longer want subscription...
  subscription.remove();
  </code></pre>
  
  <p>Native API:</p>
  
  <pre><code>var event = new Event('build');
  
  // Listen for the event.
  elem.addEventListener('build', function (e) { ... }, false);
  
  // Dispatch the event.
  elem.dispatchEvent(event);
  </code></pre>
  
  <h3>Questions</h3>
  
  <ul>
  <li>Will both do the same job? (I think so?)</li>
  <li>So is there actually any noticeable difference? Like performance? </li>
  <li>What are the pros and cons of both if both ways can be used?</li>
  </ul>
  
  <p>I personally think if you implement it yourself the API looks more elegant than using the provided API. But this is not a technical argument. :)</p>
  
  <h3>Resources</h3>
  
  <ul>
  <li><a href="https://davidwalsh.name/pubsub-javascript" rel="noreferrer">David Walsh pub/sub article</a></li>
  <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener" rel="noreferrer">addEventListener()</a></li>
  <li><a href="https://developer.mozilla.org/enUS/docs/Web/Guide/Events/Creating_and_triggering_events?" rel="noreferrer">Create and trigger events</a></li>
  </ul>