popcode icon indicating copy to clipboard operation
popcode copied to clipboard

Make multiple alerts queue, like blocking vanilla js alert()

Open razzius opened this issue 3 years ago • 0 comments

Currently if you have multiple alert calls, only the last one will be seen:

[1,2,3].forEach(alert); // shows a SweetAlert with 3

However in a standard browser, or the "popped out" document, it will display first an alert with 1, then with 2, then 3.

A bit of personal backstory here: I learned how to program in part watching Simon Allardice's Foundations of Programming on Lynda, and the language-agnostic course used javascript since everybody already has a browser and alert() to show the result of values.

I think it's pretty useful to be able to do something like

let a = 3;
alert(a);
a = 5;
alert(a);

and this patch enables it.

You can do a similar thing with console.log, but all the results show up at once, and they're hidden in the console.

This patch messy and untested, but I'm curious to see if there's any interest in incorporating something like this.

razzius avatar Mar 12 '22 00:03 razzius