{"id":16817646,"url":"https://github.com/yuwu9145/singleton-checker","last_synced_at":"2026-05-20T02:42:33.392Z","repository":{"id":57361765,"uuid":"289199320","full_name":"yuwu9145/singleton-checker","owner":"yuwu9145","description":null,"archived":false,"fork":false,"pushed_at":"2020-10-03T13:32:01.000Z","size":660,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-21T11:19:51.049Z","etag":null,"topics":["angular","decorator","dependency-injection","singleton","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/singleton-checker","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuwu9145.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-21T06:49:42.000Z","updated_at":"2023-03-07T08:14:09.000Z","dependencies_parsed_at":"2022-09-06T21:41:39.086Z","dependency_job_id":null,"html_url":"https://github.com/yuwu9145/singleton-checker","commit_stats":null,"previous_names":["yuchaosydney/singleton-checker"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuwu9145%2Fsingleton-checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuwu9145%2Fsingleton-checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuwu9145%2Fsingleton-checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuwu9145%2Fsingleton-checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuwu9145","download_url":"https://codeload.github.com/yuwu9145/singleton-checker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244039202,"owners_count":20387835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","decorator","dependency-injection","singleton","typescript"],"created_at":"2024-10-13T10:47:50.025Z","updated_at":"2026-05-20T02:42:28.349Z","avatar_url":"https://github.com/yuwu9145.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typescript Runtime Singleton Checker\nSingleton services are becoming increasingly imperative when developing large-scale frontend applications. A very common use case would be maintaining a consisten rxjs subject (state) from a service class that will be used by multiple pages (some are eager loaded while some are lazy loaded).\nAccidently creating multiple instances from the same service class will certainly break pre-defined consistent state across different pages.\n\nThis tool is a Typescript class decorator which can be easily applied to the class that you want its instance to be created only once and subsequently used as a singleton object during runtime.\nThis decorator acts as an observer of the class's constructor. When the class constructor is invoked more than once during runtime, it will print a console warning message which will\nhelp you to checkout why multiple instances are created from a given class.\n## Demo\n![](angular-demo.gif)\n## Installation\n```js\nnpm install singleton-checker\nyarn add singleton-checker\n```\n## Usage\n\n```js\nimport { singletonChecker } from 'singleton-checker';\n\n@singletonChecker\nclass SampleService {}\n```\n## Outcome\nWhen multiple instances are created from \"SampleService\" class in runtime, a warning message will be printed in console\n\n```js\n🔥 RUNTIME Singleton Checker: class SimpleService now has 2 instances running!\n```\nLicense\n----\n\nSee the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuwu9145%2Fsingleton-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuwu9145%2Fsingleton-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuwu9145%2Fsingleton-checker/lists"}