title: How to add a callback to a function in the moment when it is triggered?
body: <p>I would like to add a callback to this function: <code>Notification.requestPermission()</code>. The problem is I don't know when exactly it (that function) will be triggered, hence I think I have to bind the browser notification permission box on click or something like that, to achieve that everytime user clicks on <code>"ALLOW"</code>, <code>"BLOCK"</code> or <code>"X"(close)</code> the javascript file finds out what button was clicked on and does something like this:</p>
  
  <pre><code>if (result === 'denied')
  {
      console.log('Permission wasn\'t granted. Allow a retry.');
      return;
  }
  if (result === 'default')
  {
      console.log('The permission request was dismissed.');
      return;
  }
  if (result === 'accepted')
  {
      console.log('The permission request was accepted.');
      return;
  }
  </code></pre>
  
  <p>My problem is I don't know how it can be binded to that browser notification permission box like the one below ↓</p>
  
  <p><a href="https://i.stack.imgur.com/gICPu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gICPu.png" alt="browser notification permission box"></a></p>
  
  <p>I do not want to call the permission prompt i.e. <code>Notification.requestPermission()</code> function. I just want to detect when <code>Permission</code> was changed and do something with that result.</p>