title: How to handle Browser Refresh action on Angular 5?
body: <p>Currently, I am trying to detect browser refresh event (with F5) and then re-initialize page state once. I simply checked the router events, i.e. if the first event type is NavigationStart and event id is 1, I think a user pressed browser Refresh F5 button.</p>
  
  <p>Sample code shown in below.  However, it looks strange. are there any better way to archive the same goal? or any suggestions? thanks </p>
  
  <pre><code>export class AppComponent implements OnInit{
  
     constructor(private  router: Router) {
       this.router.events.pairwise().subscribe((events: any[]) =&gt; {
         if (events[0] instanceof NavigationStart
               &amp;&amp; events[0].id === 1 &amp;&amp; events[1].id === 1) {
  
               // re-initialize page sate . . .
      }
    });
  </code></pre>
  
  <p>}</p>