{"id":16384896,"url":"https://github.com/marcj/angular-unsub","last_synced_at":"2025-10-24T17:02:01.529Z","repository":{"id":66158417,"uuid":"161806877","full_name":"marcj/angular-unsub","owner":"marcj","description":"Unsubscribes automatically your RXJS subscriptions when component is ngOnDestroy'ed","archived":false,"fork":false,"pushed_at":"2018-12-14T16:05:35.000Z","size":2,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-02T14:44:24.111Z","etag":null,"topics":["angular"],"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/marcj.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-12-14T15:48:59.000Z","updated_at":"2019-07-16T23:37:08.000Z","dependencies_parsed_at":"2023-02-21T00:16:31.527Z","dependency_job_id":null,"html_url":"https://github.com/marcj/angular-unsub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcj%2Fangular-unsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcj%2Fangular-unsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcj%2Fangular-unsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcj%2Fangular-unsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcj","download_url":"https://codeload.github.com/marcj/angular-unsub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240121944,"owners_count":19751117,"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"],"created_at":"2024-10-11T04:12:55.513Z","updated_at":"2025-10-24T17:02:01.444Z","avatar_url":"https://github.com/marcj.png","language":"TypeScript","readme":"# Angular-unsub\n\nAutomatically unsubscribes your subscriptions of your components\nwhen the component is destroyed.\n\n## Example\n\n## `unsubscribe()` decorator\n\nA decorator for class property, which automatically calls unsubscribe() on that property value\nwhen the component is destroyed (when ngOnDestroy is called).\n\nWhen you re-assign the property value, the old one will automatically be unsubscribed as well.\n\n```typescript\n@Component({\n    template: 'Hi'\n})\nclass MyComponent {\n    @Input() data: Observable\u003cany\u003e;\n\n    @unsubscribe()\n    private sub: Subscription;\n\n    constructor() {\n        this.sub = this.data.subscribe((next) =\u003e {\n        \n        });\n        \n        //old one will be unsubscribed as well\n        this.sub = this.data.subscribe((next) =\u003e {\n        \n        });\n    }\n}\n```\n\n## `Subscriptions` class\n\nAllows to collect multiple subscriptions in one collection to simplify code.\n\n```typescript\n@Component({\n    template: 'Hi'\n})\nclass MyComponent {\n    @Input() data: Observable\u003cany\u003e;\n    @Input() data2: Observable\u003cany\u003e;\n        \n    @unsubscribe()\n    private subs = new Subscriptions();\n    \n    constructor() {\n        this.sub.add = this.data.subscribe((next) =\u003e {\n \n        });\n \n        this.sub.add = this.data2.subscribe((next) =\u003e {\n \n        });\n    }\n }\n ```\n \n ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcj%2Fangular-unsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcj%2Fangular-unsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcj%2Fangular-unsub/lists"}