Close Page properly


#1

Normally i can push and pop or setting the root page with the NavController with no complications. But in one case it didnt’t work anymore. I do a

this.navCtrl.setRoot(HomePage);

and get an Error: “Error in ./…SomePage class - caused by: …someData is undefined”.

SomePage actually needs someData to load and HomePage deletes someData, but why i get an error. ? I’m leaving SomePage and doesn’t need it anymore. Do i have to close it explicitly ?


#2

Page A should not be able to ruin Page B’s day like this. That is just asking for impossible-to-test and impossible-to-track-down bugs.


#3

Probably because the framework started HomePage before destroying SomePage. That’s asynchrony. You are guaranteed that things will eventually happen, not that they will happen in a particular order.


#4

I found a “solution”. Now i delete “someData” not in the constructor of HomePage but later. Not perfect but it works.


#5

I still think it is a major design flaw to have any page throw an error that is effectively caused by circumstances outside of its control. How can you ever test this page? You need to make SomePage capable of handling the situation when someData is not available.