Migrating ng-idle to modern Angular
ng-idle detected user inactivity, showed a warning countdown and fired a timeout event, with an optional keepalive ping to the server. The AngularJS version is tied to AngularJS.
What replaces it
| Option | When to choose it |
|---|---|
| Your own idle service | A few RxJS operators over user activity events, a timer and a warning dialog; no dependency. |
| @ng-idle/core | Same author and same concepts (Idle, Keepalive) for Angular; check that its latest release supports your Angular version. |
How to migrate it
- Write down the current rules: idle time, warning time, which events count as activity and the keepalive URL.
- Implement the idle service in Angular and downgrade it, so there is a single timer for both frameworks.
- Connect the timeout to the logout of the shared AuthService and remove ng-idle from the legacy app.
Watch out. Test with several tabs open. A user who is active in one tab must not be logged out by an idle tab; share the last-activity time through localStorage or BroadcastChannel.
Other libraries
Planning a migration or a micro-frontend platform?
In a 20-minute call you describe your situation and I tell you how I'd approach it. If it isn't worth doing yet, I'll say so.
Message me on LinkedIn