If I have a SweetAlert2 popup like this:
Swal.fire({
title: 'Warning',
icon: 'warning',
text: 'This is a warning',
confirmButtonText: 'Continue',
cancelButtonText: 'Back',
showCancelButton: true,
reverseButtons: true,
}).then((result) => {
if (result.value) {
// Do stuff
}
});
And instead of having it fire right away, I want to add it to a queue like this:
// Create array
swal_queue = [];
// Add popups to array
swal_queue.push({
title: 'Warning',
icon: 'warning',
text: 'This is a warning',
confirmButtonText: 'Continue',
cancelButtonText: 'Back',
showCancelButton: true,
reverseButtons: true,
});
p = Swal.queue(swal_queue);
p.then(function() {swal_queue = []});
How do I add the .then()
code to the queue for that popup?
I think you can wrap the swal_queue as a subscriblable queue and then subscrible on the queue, once a new item comes in popup the dialog or alert.