Recipe to detect if alert/modal is displayed in ionic 3 / ionic 4

Hi all,

I’m looking for a recipe to detect if a alert or modal is displayed (in front). My priority is for Ionic 3. The reason for this is that I need to suspend some background processing (not UI stuff) until the alert/modal is dismissed. I was using a fragile approach of disabling the activity prior to opening the alert and then re-enabling it after the model is closed. When I forget to put matching re-enabling step, the background task never starts again. Pretty bad.

For Ionic 3 I’m using AlertController / ModalController.

I haven’t gotten around to porting the code for Ionic 4 yet, but I’d need to use a similar recipe.