The more I open/close a new ActionSheetController, the more times my event publish gets fired upon close.
I serve up the app for the first time and a sliding list is generated. Each item hast a option that can trigger the showMyActionSheet(new_id) func.
As the user clicks the option the actionsheet closes and the event is published. The problem is that the more times I open up a new actionsheet and click the option the more times it loops on close and publishes the same event multiple times.
So if click on 3 different items and activate a new ActionSheet each timeā¦the 3rd actionsheet that is transistion dismiss, the event is published 3 times.
Hopefully that makes sense.
showMyActionSheet(my_id){
let actionSheet = this.actionSheetCtrl.create({
title: "Options",
buttons: [
{
text: 'Do a Dance',
handler: () => {
let navTransition = actionSheet.dismiss();
navTransition.then(()=>{
this.events.publish('mydata:update',my_id);
});
return false;
}
},
{
text: 'Delete',
handler: () => {
console.log('Delete clicked');
}
}
]
});
actionSheet.present();
}
}
In my constructor I have
events.subscribe('mydata:update', (my_id) => {
return this.changeMyAsyncFunction(my_id).then(()=>{
console.log('data updated');
});
});