{"id":15015956,"url":"https://github.com/ember-polyfills/ember-destroyable-polyfill","last_synced_at":"2025-04-12T09:31:32.129Z","repository":{"id":36976524,"uuid":"255083780","full_name":"ember-polyfills/ember-destroyable-polyfill","owner":"ember-polyfills","description":"Polyfill for RFC 580: Destroyables","archived":false,"fork":false,"pushed_at":"2023-01-23T04:10:08.000Z","size":2475,"stargazers_count":4,"open_issues_count":28,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-31T11:41:33.022Z","etag":null,"topics":["ember","ember-addon","emberjs","lifecycle","lifecycle-management","polyfill"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ember-polyfills.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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-04-12T13:03:42.000Z","updated_at":"2022-11-16T14:07:29.000Z","dependencies_parsed_at":"2023-02-12T20:32:07.592Z","dependency_job_id":null,"html_url":"https://github.com/ember-polyfills/ember-destroyable-polyfill","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-polyfills%2Fember-destroyable-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-polyfills%2Fember-destroyable-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-polyfills%2Fember-destroyable-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-polyfills%2Fember-destroyable-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ember-polyfills","download_url":"https://codeload.github.com/ember-polyfills/ember-destroyable-polyfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223510342,"owners_count":17157306,"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":["ember","ember-addon","emberjs","lifecycle","lifecycle-management","polyfill"],"created_at":"2024-09-24T19:48:12.500Z","updated_at":"2024-11-07T12:03:47.586Z","avatar_url":"https://github.com/ember-polyfills.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-destroyable-polyfill\n\n[![CI](https://github.com/ember-polyfills/ember-destroyable-polyfill/workflows/CI/badge.svg)](https://github.com/ember-polyfills/ember-destroyable-polyfill/actions)\n[![npm version](https://badge.fury.io/js/ember-destroyable-polyfill.svg)](http://badge.fury.io/js/ember-destroyable-polyfill)\n[![Download Total](https://img.shields.io/npm/dt/ember-destroyable-polyfill.svg)](http://badge.fury.io/js/ember-destroyable-polyfill)\n[![Ember Observer Score](https://emberobserver.com/badges/ember-destroyable-polyfill.svg)](https://emberobserver.com/addons/ember-destroyable-polyfill)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)  \n[![Dependabot enabled](https://img.shields.io/badge/dependabot-enabled-blue.svg?logo=dependabot)](https://dependabot.com/)\n[![dependencies Status](https://david-dm.org/ember-polyfills/ember-destroyable-polyfill/status.svg)](https://david-dm.org/ember-polyfills/ember-destroyable-polyfill)\n[![devDependencies Status](https://david-dm.org/ember-polyfills/ember-destroyable-polyfill/dev-status.svg)](https://david-dm.org/ember-polyfills/ember-destroyable-polyfill?type=dev)\n\nPolyfill for [RFC 580 \"Destroyables\"][rfc-580].\n\n[rfc-580]: https://github.com/emberjs/rfcs/pull/580\n\n## Installation\n\n```bash\nember install ember-destroyable-polyfill\n```\n\nFor addons, pass the `-S` flag.\n\n## Compatibility\n\n* Ember.js v3.4 or above; completely inert for v3.22.0-alpha.1 and above\n* `ember-cli-babel` v7.22.1 or above\n* Ember CLI v2.13 or above\n* Node.js v10 or above\n\n## Summary\n\nAdds an API for registering destroyables and destructors with Ember's built in\ndestruction hierarchy.\n\n```js\nimport { registerDestructor } from '@ember/destroyable';\n\nclass MyComponent extends Component {\n  constructor() {\n    let timeoutId = setTimeout(() =\u003e console.log('hello'), 1000);\n    registerDestructor(this, () =\u003e clearTimeout(timeoutId));\n  }\n}\n```\n\nThe API will also enable users to create and manage their own destroyables, and\nassociate them with a parent destroyable.\n\n```js\nimport {\n  associateDestroyableChild,\n  registerDestructor\n} from '@ember/destroyable';\n\nclass TimeoutManager {\n  constructor(parent, fn, timeout = 1000) {\n    let timeoutId = setTimeout(fn, timeout);\n    associateDestroyableChild(parent, this);\n    registerDestructor(this, () =\u003e clearTimeout(timeoutId));\n  }\n}\n\nclass MyComponent extends Component {\n  manager = new TimeoutManager(this, () =\u003e console.log('hello'));\n}\n```\n\nFor detailed usage instructions, refer to the\n[RFC 580 \"Destroyables\"][rfc-580].\n\n## TypeScript Usage\n\nTypeScript's normal type resolution for an import from `@ember/destroyable`\nwill **not** find this the types provided by this package (since TypeScript\nwould attempt to resolve it as `node_modules/@ember/destroyable` or under\nthe Definitely Typed location for `@ember/destroyable`). Once the\n`@ember/destroyable` API is a documented part of Ember's API, the\nDefinitely Typed folks will gladly accept adding that API, but in the\nmeantime users will need to modify their `tsconfig.json` to tell TypeScript\nwhere these types are.\n\nAdd the following to your `tsconfig.json`:\n\n```js\n{\n  // ...snip...\n  \"paths\": {\n    // ...snip...\n    \"@ember/destroyable\": [\"node_modules/ember-destroyable-polyfill\"],\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-polyfills%2Fember-destroyable-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fember-polyfills%2Fember-destroyable-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-polyfills%2Fember-destroyable-polyfill/lists"}