I think I am missing something in NativeScript (currently with Angular and testing on Android, both with latest versions).
On one hand, each of my routes, initializes some Observable Subscription (watching data change, navigation changes, services changes). On the other hand, Nativescript keep a stack of loaded/living routes..
Result : If any of my services changes, the Subscriptions on the stacked routes are still executed (which are not on screen, but can be deep in back stack)..
Is that a problem ? I mean why would those hidden routes still be active ? Doesn't it smell bad like a leak ?
So now, I'm asking, why doesn't Nativescript don't have onResume & onPause logic like on Android Sdk ? This way I could stop/resume observers from here ?
For now, I'm trying to use :
ngOnInit() {
console.log('onInit');
}
@HostListener('loaded')
onResume() {
console.log('onResume');
}
@HostListener('unloaded')
onPause() {
console.log('onPause');
}
ngOnDestroy() {
console.log('onDestroy');
}
But I don't know, I got a bad feeling about all of this, I have the feeling I'm not the one who should handle this but nativescript inner sdk. Thanks.