Is there a way to avoid having all the pages initialized in ionic? im wanting to initialize the page only when it loaded. I have read through documentation and it says that the avoiding the OnPush() event will fix the proplem im using (click) to trigger my routerOulet. Any help on this solution is appreciated in advance! Incredible framework thusfar!!
Can you back up a bit and explain what you’re trying to achieve in less technical terms? I get concerned when app code starts encroaching onto framework territory, and I consider things like page lifecycle management squarely within “framework territory”. If the framework decides for whatever reason that it wants to aggressively cache my pages (or evict them from cache), preload them, I consider that its business. If it wants to change the way it does this tomorrow, fine. If it wants to employ different strategies in different execution environments, since my app code doesn’t care, it won’t behave differently and I won’t have to field obscure bug reports on devices I don’t have.
right so i have a home page that has multiple components on it. Each of the components are handling their own service calls OnInit(). issue with subscribing to the event is that with the current set up my component cant trigger an on destroy event or ionView event because the component is a child so i have no way to unsubscribe from the child component to the parent.
parent event => child subscribes
page change
child unsubscribe? <= parent
just a small example since the children dont seem to be having access to the same lifecycle hooks as the parent from what i have seen so far
As long as ngOnInit
isn’t called twice without an intervening ngOnDestroy
, what’s the problem? If the page containing these components has been cached, but is not currently visible, why is it bad that the subscriptions are persisting in this state?
the reason is im using a @hostlistener of the screen view size on the parent and when im not on that page i dont need the data there for i should subscribe. My worry is having constant data reading while on a different page when its not concerned
Unless your users are changing device orientation ten times a second, I would not concern myself here.
ok thank you for the assistance