lifestyle
JS object life cycle management helper. Best used with Angular.
Installation
$ yarn add --dev lifestyle
Usage
This is typically used in angular application to avoid messing up your application code with explicit subscriptions and resource disposal calls.
; // ... my component code ngOnInit
How it works
It stores all pushed disposers to in a WeakMap associated with passed "this". Full implementation is https://github.com/vivainio/lifestyle/blob/master/src/index.ts.
This is more convenient and harder to screw up than takeUntil(this.destroy$)
pattern,
especially if you end up going to subscribe() anyway.
Size is ~ 500 bytes uncompressed, and there are no dependencies.
License
MIT. Copyright (c) 2019 by Ville M. Vainio vivainio@gmail.com