Is it possible tout catch all page lifecycle event? How should i do this?
I need to add call to some method on each page load and page leave. So I suppose I can catch ionViewDidEnter and leave. But I want to put my code in one place without implement these methods in each pages. …
It can be seen like cross cutting concern. I already think about AOP. But I don’t find documentation for that with ionic and angular 2
Wondering if it isn’t possible to extend an arbitrary class that has this methods implemented?
Something like:
export class SignUp extends MyClassWithHooks {
...
class MyClassWithHooks {
ionViewDidLoad() { //etcetcetc
}
I am not sure that it’s the right way.
Suppose you have the following code.
export class SignUp extends MyClassWithHooks {
ionViewDidLoad() {
// Local stuff
}
}
class MyClassWithHooks {
ionViewDidLoad() {
// Never called for SignUp
}
}
In my case I need execution of both.
And I don’t want to use super() … and extends all pages.
If I start like this, when I will add a new page, me or my colleagues will forget something like super.ionViewDidLoad(). Sur about that at 99%.
Moreover, in this cas, I just need to implement the ionViewDidLoad and directly call my common stuff via a service or something like that. It’s not the intent.
I am sure it’s possible to register some event, use some decorator or other technique. But I don’t find the right way .