I have two kinds of alerts- secondary alerts and delayed alerts Secondary alert messgaes are shown at first and user has to hit OK button to close it.
But there are delayed alerts also..which are triggered by a setTimeout()
I'm trying to automatically close secondary alerts when this delayed alert is shown to user
I tried to dismiss the secondary alerts like this
this.secondaryAlertVar.dismiss();
But it's not working.
Here's the code
import { Component, OnInit } from "@angular/core";
import * as dialogs from "tns-core-modules/ui/dialogs";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html",
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
secondaryAlertVar: any;
constructor() {
this.secondaryAlerts(function () { }, 0, "Hhmm... ", "Alert");
setTimeout(() => {
this.delayedAlertBox("All other alerts should close automatically when this triggered");
}, 10000);
}
ngOnInit() {
}
secondaryAlerts(callback, mode, message, title): any {
this.secondaryAlertVar = dialogs
.alert({
title: title,
message: message,
cancelable: false,
okButtonText: "OK"
})
.then(callback);
}
delayedAlertBox(message) {
this.secondaryAlertVar.dismiss();
var options = {
title: "Delayed Alert",
message: message,
okButtonText: "Ok",
cancelable: false,
};
dialogs.alert(options).then(() => {
});
}
}
rxjs
for this. If you did - you could possibly useobservable.pipe(takeUntil(delayedAlertBoxState$))
and play around that. :) – Frannypromise
and you should be able to hook into that withfrom
. – Franny