title: Protractor: best way to wait for custom event
body: <p>In my test case, using protractor, I have to wait for a custom event.</p>
  
  <p>My actual way to wait is inject a temporary function that changes a boolean and then wait for that boolean to change.
  In other words:</p>
  
  <pre><code>browser.executeScript('window.on("customEvent", function(){ 
      window.hasBeenTriggered=true;
    })
  )')
  browser.driver.wait(function(){
     return browser.executeScript('return window.hasBeenTriggered;'     )===true;
   });
  </code></pre>
  
  <p>Is there a better way to wait for custom event in protractor?
  How do you wait for custom event?
  Does protractor's API offer a method for doing it?</p>