I have a page on which list of people in the array will display if I removed any of them the array is getting updated to reflect that change I’m using DoRefresh function to refresh the page. To update the array i’m using several functions and I wrote them in the IonviewWillenter method. if i’m calling this ionviewillenter in my dorefresh function the list is getting updated but the previous values are not going . to remove the previous values what should i do or there is any other method of refreshing
doRefresh(event) {
console.log('Begin async operation');
setTimeout(() => {
this.ionViewWillEnter();
console.log('Async operation has ended');
event.target.complete();
}, 2000);
}
ionViewWillEnter() {
this.followers();
this.getuserfollowing();
setTimeout(() => {
console.log('set timeout');
if (this.hasfollowers == true && this.hasfollowing == true) {
this.getstats();
}
}, 1000);
}
``
this is my code ![Screenshot (21)|690x388](upload://f4BCzJDXxaNlcLc7lu4Aq09jFa4.png)
Not sure if I understood well… Your updated values aren’t getting reflected on template? In that case can you confirm that they get updated indeed (console log them after update)?
It’s not a whole lot of an exaggeration to say that “giving you a way to elegantly not do this” is one of the major reasons libraries like RxJS and frameworks like Angular even exist in the first place.
You virtually never want setTimeout in an Ionic app. You definitely never want setTimeout with a magic number, if for no other reason than you can never know if you’ve chosen the right one.
Other things I see here that are fraught with peril, should only be done if you know exactly what you are doing and why, and should be extensively commented to explain why you are deviating from normal procedure: the == operator (always use === instead) and explicit comparison against true instead of using implicit truthiness.
Finally, this post suggests what I would do instead of involving lifecycle events here at all.