Unsubscribe from observables on component destruction
Summary of the new feature/enhancement
Subscriptions to observables don't get automatically terminated on component destruction and this can lead to memory leaks. We need to make sure to explicitly terminate the subscriptions and avoid these potential leaks.
Justify the new feature/enhancement
This will make the application:
- Avoid memory leaks
- Run just a little bit smoother, especially when the same component is loaded many times and subscriptions stack
- Follow the recommended design patterns when using RxJs
Proposed technical implementation details (optional)
Use takeUntil()
piped into the observable and then be told to complete on component destruction.
References
Mirror issue in Teachers: universis-teachers#148
Edited by George Katsikas