Title: Calling effect cleanup multiple times not working · Issue #58211 · angular/angular · GitHub
Open Graph Title: Calling effect cleanup multiple times not working · Issue #58211 · angular/angular
X Title: Calling effect cleanup multiple times not working · Issue #58211 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Calling the effect cleanup multiple times inside the effect function only considers the last cleanup one. I don't know whether it is a bug ...
Open Graph Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Calling the effect cleanup multiple times inside the effect function only considers the last cleanu...
X Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Calling the effect cleanup multiple times inside the effect function only considers the last cleanu...
Opengraph URL: https://github.com/angular/angular/issues/58211
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Calling effect cleanup multiple times not working","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncore\n\n### Is this a regression?\n\nYes\n\n### Description\n\nCalling the effect cleanup multiple times inside the effect function only considers the last cleanup one. I don't know whether it is a bug or missing feature. Till today i thought it is supported similar to `DestroyRef`.\n\n```ts\n\nclass TestComponent {\n constructor() {\n effect((onCleanup) => {\n const target = this.target();\n ....\n const resizeObserver = new ResizeObserver(() => {\n ....\n });\n resizeObserver.observe(target());\n onCleanup(() => resizeObserver.disconnect());\n\n if (checkScroll) {\n target.addEventListener('scroll', this.updateDimension);\n onCleanup(() => target.removeEventListener('scroll', this.updateDimension)); // Only this cleanup gets called\n }\n });\n }\n}\n```\n\n\n### Please provide a link to a minimal reproduction of the bug\n\n_No response_\n\n### Please provide the exception or error you saw\n\n_No response_\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\nAngular CLI: 18.1.1\nNode: 20.17.0\nPackage Manager: pnpm 9.8.0\nOS: win32 x64\n\nAngular: 18.1.1\n... animations, cdk, cli, common, compiler, compiler-cli, core\n... forms, platform-browser, platform-browser-dynamic\n... platform-server, router, ssr\n\nPackage Version\n---------------------------------------------------------\n@angular-devkit/architect 0.1801.1\n@angular-devkit/build-angular 18.1.1\n@angular-devkit/core 18.1.1\n@angular-devkit/schematics 18.1.1\n@angular/build 18.0.0\n@schematics/angular 18.1.1\nng-packagr 18.1.0\nrxjs 7.8.1\ntypescript 5.4.5\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/sheikalthaf","@type":"Person","name":"sheikalthaf"},"datePublished":"2024-10-15T17:03:44Z","url":"https://github.com/angular/angular/issues/58211"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6bcfd07b-58a0-7496-fc03-26b46cc37098 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCEC:AFBD9:1332745:195EF7B:6B01EF9A |
| html-safe-nonce | 125cca2a07059c07a7121a5025876aca13dc37b3adfcb446872ff66a6ba1acd1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0VDOkFGQkQ5OjEzMzI3NDU6MTk1RUY3Qjo2QjAxRUY5QSIsInZpc2l0b3JfaWQiOiI0MTU2MzA2NDI2MTI3NTc2OTg3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f5cfe3e3605f2bbc617a2d5b47358805e5a332f7c1bbcf2be5ed2797edf35616 |
| hovercard-subject-tag | issue:2589371257 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/58211/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84ee8669eda8bebe72cfbd66f3685219f0ea918a8bd30150c57f6774fd051710/angular/angular/issues/58211 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84ee8669eda8bebe72cfbd66f3685219f0ea918a8bd30150c57f6774fd051710/angular/angular/issues/58211 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Calling the effect cleanup multiple times inside the effect function only considers the last cleanu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sheikalthaf |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width