{"id":47870202,"url":"https://github.com/jackjamieson/ng-timeout","last_synced_at":"2026-04-04T00:47:53.573Z","repository":{"id":68297765,"uuid":"156275674","full_name":"jackjamieson/ng-timeout","owner":"jackjamieson","description":"Creates observables for user idle and timeout with manual interrupts.","archived":false,"fork":false,"pushed_at":"2019-02-06T14:13:13.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-04T00:47:51.935Z","etag":null,"topics":["angular","idle","timeout"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jackjamieson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-05T20:04:54.000Z","updated_at":"2019-02-06T14:13:15.000Z","dependencies_parsed_at":"2023-02-25T10:30:53.349Z","dependency_job_id":null,"html_url":"https://github.com/jackjamieson/ng-timeout","commit_stats":{"total_commits":7,"total_committers":2,"mean_commits":3.5,"dds":0.4285714285714286,"last_synced_commit":"9fdb528cb6ccbf475576eaeb2a611b6527a7d8e6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jackjamieson/ng-timeout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackjamieson%2Fng-timeout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackjamieson%2Fng-timeout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackjamieson%2Fng-timeout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackjamieson%2Fng-timeout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackjamieson","download_url":"https://codeload.github.com/jackjamieson/ng-timeout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackjamieson%2Fng-timeout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31383635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T23:20:52.058Z","status":"ssl_error","status_checked_at":"2026-04-03T23:20:51.675Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","idle","timeout"],"created_at":"2026-04-04T00:47:52.982Z","updated_at":"2026-04-04T00:47:53.560Z","avatar_url":"https://github.com/jackjamieson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ng-timeout\n**This is the version-agnostic project for https://github.com/jackjamieson/ng2-timeout**\n\nI will not be updating ng2-timeout although in my testing it was working up to Angular 7.\nThis project is recreated in Angular's new library generation and will be much easier to update and maintain.\n\nCreates observables for user idle and timeout with manual interrupts.  Detects interrupts across browser tabs with [storage-emitter](https://github.com/alekseykulikov/storage-emitter).\n\n## Installation\n\nTo install this library, run:\n\n```bash\n$ npm install ng-timeout storage-emitter --save\n```\n\n## Consuming library\n\nImport library in any Angular application from your Angular `AppModule`:\n\n```typescript\n// Import library\nimport { NgTimeoutService } from 'ng-timeout';\n\n@NgModule({\n  declarations: [\n    ...\n  ],\n  imports: [\n    ...\n  ],\n  providers: [ NgTimeoutService ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\nTo use the module I recommend injecting the service into your top level app component.  \nFrom there you can control what causes interrruptions to the timers and how you want to handle idle or timeout.\n\n```typescript\nimport { NgTimeoutService } from '../ng-timeout';\n\nprivate idleState: string; // if you want to show the countdown for example\n\nconstructor( private timeoutService: NgTimeoutService ) {\n\n  this.timeoutService.setTimeToIdle(60 * 10); // 10 minutes of no interrupts will set the user to idle\n  this.timeoutService.setTimeToTimeout(60); // 1 minute of no timeout interrupts will set the user as timed out\n\n  // subscribe to the idle observable\n  this.timeoutService.watchIdle().subscribe((isIdle: boolean) =\u003e {\n    if (isIdle) {\n      //  do something if the user becomes idle\n    }\n  });\n\n  this.timeoutService.watchTimeout().subscribe((countdown: string) =\u003e {\n    this.idleState = countdown;\n    if(+countdown \u003c= 0){\n      // do something about the timeout\n    }\n  });\n}\n```\n\nHere is an example `@HostListener` for detecting keypress\n\n```typescript\n@HostListener('document:keypress', ['$event'])\nhandleKeyboardEvent(event: KeyboardEvent) {\n  this.timeoutService.interruptIdle(); // interrupt the idle countdown and reset the timer if a key was pressed\n  this.timeoutService.interruptTimeout(); // for illustration purposes we can also reset the timeout when a key is pressed\n\n}\n```\n\n\n\n## Development\nThe parent Angular project is included with this so it should be easy to set up and update.\nFollow Angular's guide on creating libraries.\n\n- npm install\n- edit projects/ng-timeout\n- ng build ng-timeout\n- output is in the dist folder\n\n\n## License\n\nMIT © [Jack Jamieson](mailto:jamieson.jack@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackjamieson%2Fng-timeout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackjamieson%2Fng-timeout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackjamieson%2Fng-timeout/lists"}