title: Extjs6 Custom js event
body: <p>I have the following flow: before the app launches I want to check something on the server. Based on the response I want to make a decision. I've created an utility class that wraps my js event and also an app controller.</p>
  
  <p>Bellow is app controller:</p>
  
  <pre><code>Ext.define('MyApp.controller.AppController', {
      extend: 'Ext.app.Controller',
      appEventDispatcher:function (){
        // Create a dummy DOM element 
          var dummy = document.createTextNode('');
  
          // Create custom wrappers with nicer names
          this.off = dummy.removeEventListener.bind(dummy);
          this.on = dummy.addEventListener.bind(dummy);
          this.trigger = function(eventName, data){
              if( !eventName ) return;
              var e = new CustomEvent(eventName, {"detail":data});
              dummy.dispatchEvent(e);
          }
      }
   });
  </code></pre>
  
  <p>And my utility class:</p>
  
  <pre><code>Ext.define('MyApp.util.Util', {
  
      statics : {
          checkSomethingOnServer: function(customEvent){
              var store = Ext.StoreManager.lookup('appStore');
              store.load({
                  scope: this,
                  callback: function(records, operation, success){
                      if (success === true){
                          customEvent.trigger('success', true);
                      if (success === false)
                          debugger;
                          customEvent.trigger('fail', true);   
                      }
                  }
              });
          }
  
      }
  });
  </code></pre>
  
  <p>Using the utility class I load a store. In the callback method, I trigger my custom event. This event is handled in the app.js file.</p>
  
  <p>The code works in fiddle and also using app watch, when I want to build the code some errors are occurring complaining(syntax error).</p>
  
  <p>I've created also a <a href="https://fiddle.sencha.com/#view/editor&amp;fiddle/21f9" rel="nofollow noreferrer">fiddle</a>.</p>
  
  <p>How to create a custom event in ExtJS and how to use it? I need the same behavior as with the js event but Extjs implementation.</p>