title: AngularJS $idleProvider and $keepaliveProvider in Angular2
body: <p>In <strong>AngularJS 1.*</strong> there are two providers that arevery useful, <code>$idleProvider</code> and <code>$keepaliveProvider</code>. I used these to handle session timeouts and automatically logout user's in previous project's. We are starting a new project now from the group up with <strong>Angular2</strong> and I want to know if there is a plan for having similar support to these? Ideally we could have a mechanism that automatically logs out the user from the client. Here is the snippet of the source from how we accomplished this in <strong>AngularJS</strong> -- how can this be done with <strong>Angular2</strong>?</p>
  
  <pre><code>// Configure Idle Session Timeout 
  userModule.config([
      'KeepaliveProvider', 'IdleProvider',
      ($keepaliveProvider, $idleProvider) =&gt; {
          var str = $('#IdleSessionTimeout').text();
          var idleTimeOut = parseInt(str);
          var interval = 60;
          if (isNaN(idleTimeOut)) {
              idleTimeOut = 20;
              interval = 10;
          } else {
              idleTimeOut *= 60; // Convert minutes -&gt; seconds
          }
          $idleProvider.idle(idleTimeOut);
          // If we ever want to warn user they are about to timeout
          //$idleProvider.timeout(5); 
  
          $keepaliveProvider.interval(interval);
      }
  ]);
  
  userModule.run(($rootScope) =&gt; {
      $rootScope.$on('IdleTimeout', () =&gt; {
          // On timeout, end the user session by redirecting to logout
          var url = window.location.href;
          url = url.replace(/\/\#.*$/, "/Account/Logout");
  
          window.location.href = url;
      });
  });
  
  // Activate Timeout Monitoring
  userModule.run(['Idle', ($idle) =&gt; {
      $idle.watch();
  }]);
  </code></pre>
  
  <p>Please help...</p>