{"_id":"@elie29/autodestroy","_rev":"4-dd1fa4e3eb0d76ea27d1f4ffdadb0a06","name":"@elie29/autodestroy","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1-alpha.1":{"name":"@elie29/autodestroy","version":"1.0.1-alpha.1","author":{"name":"Elie NEHME"},"description":"A simple RxJs operator that handles subscription cancellation automatically","license":"MIT","main":"./dist/index.js","typings":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/elie29/autodestory.git"},"bugs":{"url":"https://github.com/elie29/autodestory/issues"},"homepage":"https://github.com/elie29/autodestory","keywords":["angular","rxjs","pipe","takeUntil","cancel subscription","component","auto destroy"],"scripts":{"tsc":"tsc","build":"rm -rf dist && npm run tsc","test":"jest","test:coverage":"jest --coverage","coveralls":"jest --coverage && cat ./coverage/lcov.info | coveralls","pub":"npm run build && npm publish --access public"},"peerDependencies":{"rxjs":"^6.3"},"devDependencies":{"@types/jest":"^24.0.18","@types/lodash":"^4.14.141","coveralls":"^3.0.6","jest":"^24.9.0","rxjs":"^6.3","ts-jest":"^24.1.0","ts-node":"^8.4.1","typescript":"^3.6.3"},"gitHead":"5b84693bc032770246433838f9dc7a64618f2959","_id":"@elie29/autodestroy@1.0.1-alpha.1","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-GllnlcdO7lXFtWD+qbF74vKTbW3YpMlksrJv053frSwvIotS67HvEgBsoznswYarQnGMhpqUfOkeV0HqNJf0JQ==","shasum":"ad1b735816926decd8913157f8666461eb4ddb05","tarball":"https://registry.npmjs.org/@elie29/autodestroy/-/autodestroy-1.0.1-alpha.1.tgz","fileCount":10,"unpackedSize":8231,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdo37ECRA9TVsSAnZWagAA3WEP/0wUQ82dp7h+P3iUcly6\nmEc6suXjjNspSCdil+olwQ/0m5cYDYgDkXe3PjhosSzzR6KCMhhJJy7MCyEy\n441c/6wRRtb3aAghWi11v0poJSEGTcJZ+QKlYlYD0gFIxQ3BsjzyW3ZNmOzF\nca8jBdlX/TxSvBWOQIywhR6HVSXruxOp8/0Z4rwRZVhEAOzFOOUjmr6H/dPm\nu+DaOQ4aRj7n16GlNPOaG65f4lCTcV+aEo68k+mPNhcWZDo2aY7+pt8do+GP\nvlINM1NGZHLRj13YCGC73le7/G+Vtrf1FvCkcYczJ1BcsDkPfigIwKNphmKA\n9yBJAvN/DTgB/3OTdrfy4j5fqTOgkmOddolQwXqRex1mex5LFzPZ57TkodOu\nfberlVI1lo1GJlIvzE6NG54Z/fQFVjYxovLANzlJTLCbTPhzdvhvvmHKl6tN\nYJjLGuDkpCwgkahUvrDQBZPdMzNx+Bcp5cqbelAnGlhMewz1jJXufLxrpcL8\nxSWzgkgrwBne6m9JnBcobseM48mm5R9t/gv0X48tBWv4HH4ZrumVlVoErz0j\n55Ip3VmrdnuVcP0dLGVXqTFvg4cvOXnSD1TpFhIpI2AuSR3+cyXeoC7u7ot2\nqvebgLWjCrrZQKoGjwxAt84YtxyDLSjWgWVQPOOW1siBnr+m0oE0fLbVtkAH\nUKhZ\r\n=/vgB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGLuBB+5zrvAeSVI+UzbjZi7YUgKw8u7mBCGtl7d898SAiEArxuyiR1O9TpeFMFqCDHvIAuu363oIc0gCJp1eUa8zR8="}]},"maintainers":[{"name":"elie29","email":"elie29@gmail.com"}],"_npmUser":{"name":"elie29","email":"elie29@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/autodestroy_1.0.1-alpha.1_1570995907614_0.9300498018890013"},"_hasShrinkwrap":false},"1.0.1-alpha.2":{"name":"@elie29/autodestroy","version":"1.0.1-alpha.2","author":{"name":"Elie NEHME"},"description":"A simple RxJs operator that handles subscription cancellation automatically","license":"MIT","main":"./dist/index.js","typings":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/elie29/autodestory.git"},"bugs":{"url":"https://github.com/elie29/autodestory/issues"},"homepage":"https://github.com/elie29/autodestory","keywords":["angular","rxjs","pipe","takeUntil","cancel subscription","component","auto destroy"],"scripts":{"tsc":"tsc","build":"rm -rf dist && npm run tsc","test":"jest","test:coverage":"jest --coverage","coveralls":"jest --coverage && cat ./coverage/lcov.info | coveralls","pub":"npm run build && npm publish --access public"},"peerDependencies":{"rxjs":"^6.3"},"devDependencies":{"@types/jest":"^24.0.18","@types/lodash":"^4.14.141","coveralls":"^3.0.6","jest":"^24.9.0","rxjs":"^6.3","ts-jest":"^24.1.0","ts-node":"^8.4.1","typescript":"^3.6.3"},"gitHead":"738d74179f2ac995ccbf6a8b652afe4d66f875da","_id":"@elie29/autodestroy@1.0.1-alpha.2","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-C+wJ218Y0aw7ZuaFyARCygiOIRF2HGkXk+m7jAO+EOgTuKKjpPYOKyry708OxuGsSgx/N0+RFK0QlWBhz/UBmw==","shasum":"d9ff93ea4c90b8d3a2a1d983c887539e417eadab","tarball":"https://registry.npmjs.org/@elie29/autodestroy/-/autodestroy-1.0.1-alpha.2.tgz","fileCount":10,"unpackedSize":7913,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdpMsSCRA9TVsSAnZWagAAlgAP+wbzp4V9u7XgzUvbm2Y1\ngqGcdP0LrOHqyDNkz+SOjW0pPTxrrtmh9SWLkZPzoigEasryPpfkp0zbCZTp\nIuKSkcKzdm+O9M3o+LpH6Z95d3XdGWmwvwJ0aeg9tCCk/Li6tftl8WHHO9i6\nt+kY39CMpXeIsXQyBWpQOZKs2gIfcSiahDh+p5OW6vPUDA9FNADzXZ4NwfbL\na4bzkzy1B+VxQSY1R/FSe+fuS49flEaV9VAt/21Nv5GZOBHNTh4pS0a0dhJv\nkZH9Iy7+y9g0ZDjMbDXyB9V6sUG3O7snpHTJQbFBOzfx5l4LB90QCc9ASA9S\nDZb99qCdfp+ET2uzwy28tzkpTIjl5MUA414U1/E/N5dPzsvbW/wjUpFtkWlf\njDJ+b6sUPBAhgbgL72Ql0Yid1uzar9qv0bFFmuiF3foRJ5lI98+C7ktm0Fze\nSJjMcQ7THtXd/NU3/m/JFij+67riP4OPx5i1hsEbyCVTbHYvQpWU7/fTDgqu\nhjpwaYKLGm857GoMyF1QsGgeypERpQXPpwrMGdCA2FjrIQuKBXj6sDZtS3B5\nCCQ9nDeBtI33aovrJFdC+xr3bX8feXa3+RtG7cjC3BD/RtkqwSNENc1xI6QV\nR0UEe+CA1dC+3SmkjPkhxq5NtcpLmBx/0pgaaGvMpy7qMGryij6mK7MxSED+\nbWUJ\r\n=JJpm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF9Fogp6r6UKYxSjl74yuSTs8gWxyj+HpDKz66qW/k9RAiBKnko33y5n2EEyjXt5JzYMmvAequd/QraDEXngFSmtYA=="}]},"maintainers":[{"name":"elie29","email":"elie29@gmail.com"}],"_npmUser":{"name":"elie29","email":"elie29@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/autodestroy_1.0.1-alpha.2_1571080977424_0.8406954070169181"},"_hasShrinkwrap":false},"1.0.1":{"name":"@elie29/autodestroy","version":"1.0.1","author":{"name":"Elie NEHME"},"description":"A simple RxJs operator that handles subscription cancellation automatically","license":"MIT","main":"./dist/index.js","typings":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/elie29/autodestory.git"},"bugs":{"url":"https://github.com/elie29/autodestory/issues"},"homepage":"https://github.com/elie29/autodestory","keywords":["angular","rxjs","pipe","takeUntil","cancel subscription","component","auto destroy"],"scripts":{"tsc":"tsc","build":"rm -rf dist && npm run tsc","test":"jest","test:coverage":"jest --coverage","coveralls":"jest --coverage && cat ./coverage/lcov.info | coveralls","pub":"npm run build && npm publish --access public"},"peerDependencies":{"rxjs":"^6.3"},"devDependencies":{"@types/jest":"^24.0.18","@types/lodash":"^4.14.141","coveralls":"^3.0.6","jest":"^24.9.0","rxjs":"^6.3","ts-jest":"^24.1.0","ts-node":"^8.4.1","typescript":"^3.6.3"},"gitHead":"da28e20c1f12207a9a939451bc2e45d0c0e9b321","_id":"@elie29/autodestroy@1.0.1","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-3LpBP9gGGrh7YEsfVYZWR1Wxf22+UH2N8yEv8DB/BZ0wwjiEBmpQNS10gW4i4EYhiF83gDqEEjLKDxAKTA49Sw==","shasum":"e3aff1bb476bbd077b7ad3de371ca60ad246752d","tarball":"https://registry.npmjs.org/@elie29/autodestroy/-/autodestroy-1.0.1.tgz","fileCount":9,"unpackedSize":7614,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdpbn6CRA9TVsSAnZWagAAUZsQAJxjAM02Q1dQwIPY67fr\n/M5GSxd1FTaUvyIi/oJmPf0yqWkaVp1vZj6FFG2tTsbfMy5gKBL9RLfyOMfr\nSBNdXAKzCGgpROaRmmbC9VuoeN617WsSDJjaY6JgJ/uUvnFghPq8T1h6Scml\np+tkUH6IvG3WY6hm1As99Va4ve6h9xCKpAfJyUMpMwrQC+9e8yOYgbdzr7kM\nQWcphsFBg9WTqzwmPIKYphooiyTV93k32y5KqpijVQSfqNRQgaA5vF8lObDj\n3Wj3XYvNPAO1F1CdkleDKpW/TD51EZd2zqJvx/K/QcstC/qSrj7lt9y5kYWq\nmrWn3PvYj+MYEUlZ/P7/xUkQARUvXxpjDk0v1PwtcgkjQ0W7SLZ+XqW7G3Kh\n7+wHu10jZWZMXJ00U9CDvi9WV/S1hzpGMEsB0xCJN/m3eU5ijH8dDoVydabE\nPPISTDKAq5bwRjoWEhEn8g8HMYTDMIDw0JoFNGn69oGISGZO23cFDfKgEPuB\nWBl1EugozheNR9UP0rqHGCLxfnuxR17RCcNUfzrdUzIMjaKzNmqpPJfFDd/9\nlIJ/tOjMuVKKFhoKT7nsbfpkaF2Pnt7/Iu67zSvr8DWEz9kL553MCCQLsi0J\n7Bazrd0sK+DHwOLq7aIHcNVACFjk/UDMl7M/G14X7pxQC5L+iDVVUaZi64gE\nPQb+\r\n=QjAk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBgn9K3NkexMkVp1EbSgTF7KdYeDKoc43piLwUPkxkjqAiALL23wcCu/vEA5xAtHACEvruJlre7ZwzmEDqT3mm9i6Q=="}]},"maintainers":[{"name":"elie29","email":"elie29@gmail.com"}],"_npmUser":{"name":"elie29","email":"elie29@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/autodestroy_1.0.1_1571142137707_0.589903266022674"},"_hasShrinkwrap":false},"1.0.2":{"name":"@elie29/autodestroy","version":"1.0.2","author":{"name":"Elie NEHME"},"description":"A simple RxJs operator that handles subscription cancellation automatically","license":"MIT","main":"./dist/index.js","typings":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/elie29/autodestory.git"},"bugs":{"url":"https://github.com/elie29/autodestory/issues"},"homepage":"https://github.com/elie29/autodestory","keywords":["angular","rxjs","pipe","takeUntil","cancel subscription","component","auto destroy"],"scripts":{"tsc":"tsc","build":"rm -rf dist && npm run tsc","test":"jest","test:coverage":"jest --coverage","coveralls":"jest --coverage && cat ./coverage/lcov.info | coveralls","pub":"npm run build && npm publish --access public"},"peerDependencies":{"rxjs":"^6.3"},"devDependencies":{"@types/jest":"^24.0.18","@types/lodash":"^4.14.141","coveralls":"^3.0.6","jest":"^24.9.0","rxjs":"^6.3","ts-jest":"^24.1.0","ts-node":"^8.4.1","typescript":"3.6.5"},"gitHead":"5b437ad35a73abea02c03745a6625f5f263dc131","_id":"@elie29/autodestroy@1.0.2","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-uyGJbcxOq+oSLWudEPlzkKkO99SeKv/HglsZUfNSx65yTQI0yZUnub3lzmRXdi9Xs1oXfFukYngCoZ0uJrsXHQ==","shasum":"b07592cc8db3f65cdc602e4c20d670328aa473dc","tarball":"https://registry.npmjs.org/@elie29/autodestroy/-/autodestroy-1.0.2.tgz","fileCount":10,"unpackedSize":8297,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfs4lWCRA9TVsSAnZWagAAd8MP/1a8pAoMnvMNwi/VWwdf\niWuNTKKZDghnUiOl0JQpbC/rAJM5FAj6JjpLkXEbgy+KDBgQ6rB+lBSxufvr\nKnLgMJlX/6fh0XLJj11wQNfX3GHusHEafQgbpFH8orLs+pym026Dn5uDWK+j\nnLgjzd8YIfbmVDnzTjG4eZcb6uyrpJRtEHiOFj5YtcXZtBfJ9u5F8NyWUQ9t\n05e8qRQOR8186RSej9GPziLhO+aJ8kD97gu3XBAfvA+jI/ZvR/rHPsO6fM43\ngWF9ZBPm/Ai/O1e681CGFqgRv2o/C/4y9woMXxoCFoWdfhpWgGu/Ygp5+YtV\nIt+4WB44uJigD3uhM7PMswDo8c/fwpH15mJwfu7LVTQQuN5Bo0lInc1Jn0gp\npkUdiSNB+lxNdkkzPI7f83kUIIUYu6m86w+T6vZ1QFPWIQrjgQ6bjH9ij9ck\n0ipMfScVUUvZ6/nraht++dlqtOP4ga+lDU7htt4KVWtimLZmJy/q3mOrwC0Y\naFBayZeGK6zTA+Vj1z4l+scOBZnHSu8LTD0ZB41K5B2LZn91rwS+WIiUk5BE\nQ1u59vyVyPK8u9fv+i6Qgc0T3MwCRLxDN0Tt1hjKCwPAj8D6JdtAwoHh5POv\np5ecKSyUFZSPOAj2QgqURpv9dW3oJrGQZaR6SMzHB/PPngSx4l+9se5SA11q\nc3JR\r\n=IWUb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD44qljKiMCsOxhUd6NgFSJsddkT8JIWb419xyKpz4HFgIgYDccgDWXSMfozIaD9OGTB12Z+kylw55xDaaX/Y6Qt3U="}]},"_npmUser":{"name":"elie29","email":"elie29@gmail.com"},"directories":{},"maintainers":[{"name":"elie29","email":"elie29@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/autodestroy_1.0.2_1605601622418_0.8160650397584557"},"_hasShrinkwrap":false}},"time":{"created":"2019-10-13T19:45:07.409Z","1.0.1-alpha.1":"2019-10-13T19:45:07.723Z","modified":"2022-04-05T07:11:43.338Z","1.0.1-alpha.2":"2019-10-14T19:22:57.544Z","1.0.1":"2019-10-15T12:22:17.859Z","1.0.2":"2020-11-17T08:27:02.638Z"},"maintainers":[{"name":"elie29","email":"elie29@gmail.com"}],"description":"A simple RxJs operator that handles subscription cancellation automatically","homepage":"https://github.com/elie29/autodestory","keywords":["angular","rxjs","pipe","takeUntil","cancel subscription","component","auto destroy"],"repository":{"type":"git","url":"git+https://github.com/elie29/autodestory.git"},"author":{"name":"Elie NEHME"},"bugs":{"url":"https://github.com/elie29/autodestory/issues"},"license":"MIT","readme":"# Auto Destroy\r\n\r\n[![Build Status](https://travis-ci.org/elie29/autodestroy.svg?branch=master)](https://travis-ci.org/elie29/autodestroy)\r\n[![Coverage Status](https://coveralls.io/repos/github/elie29/autodestroy/badge.svg?branch=master)](https://coveralls.io/github/elie29/autodestroy?branch=master)\r\n[![Open Source Love](https://badges.frapsoft.com/os/v3/open-source.svg?v=102)](https://github.com/elie29/autodestory)\r\n\r\n## Problem\r\n\r\nWhen we use RxJS, we have to cancel all subscription objects we create. In angular, we have the possibility to use [async pipe](https://angular.io/api/common/AsyncPipe). However, in some use cases, we don't have this opportunity and we need manually to unsubscribe each subscription or complete the Observable by using takeUntil.\r\n\r\nAlthough, we have to duplicate the same code over and over, the implementation of this pattern becomes repetitive for each component that uses subscriptions.\r\n\r\n## Solution\r\n\r\nAuto destroy library offers a single autoDestroy operator method. It overrides any existent destroy method to handle automatically subscription cancellation on any observable.\r\n\r\n## How it works\r\n\r\nWe can use the autoDestroy operator along with angular component as follow:\r\n\r\n```TS\r\nexport class PostComponent implements OnDestroy {\r\n  constructor(postService: PostService) {\r\n    postService.getPosts()\r\n      .pipe(\r\n        switchMap(...)\r\n        ... other observables\r\n        // to prevent leaks with intermediate observables, this **MUST** be the last operator !!\r\n        autoDestroy(this)\r\n      )\r\n      .subscribe();\r\n  }\r\n\r\n  // must be implemented even empty\r\n  ngOnDestroy(): void {}\r\n}\r\n```\r\n\r\nThe autoDestroy operator is RxJS specific and not related to Angular. Thus, it can be used with any Observable as follow:\r\n\r\n```TS\r\nexport class AuthorComponent {\r\n  constructor() {\r\n    timer(0, 300)\r\n      .pipe(\r\n        map(next => next * 3),\r\n        filter(next => next % 2 !== 0),\r\n        autoDestroy(this, 'destroy') // default method name is ngOnDestroy\r\n      )\r\n      .subscribe();\r\n  }\r\n\r\n  private log(message: string): void {\r\n    console.log(message);\r\n  }\r\n\r\n  // original destroy method would be called automatically\r\n  destroy(message: string): void {\r\n    this.log(message);\r\n  }\r\n}\r\n```\r\n\r\n## Peer Dependency\r\n\r\nThe auto destroy pipe depends on:\r\n\r\n1. RxJS ^6.3\r\n\r\n   - Observable\r\n   - Subject\r\n   - takeUntil\r\n\r\n2. Typescript 3.6.5\r\n\r\n## Publish to npm repo\r\n\r\n1. Fix date release in CHANGELOG.md\r\n1. Increment version number in package.json and package-lock.json\r\n1. Run `npm run pub` then enter the 2FA code\r\n1. Commit, push and create a new github release\r\n","readmeFilename":"README.md"}