Popup from method call for showing error to user

If you’re executing a script, checking say that a chosen value is not a duplicate in an array you’re holding, how can you pop up a message to the user, from the script?

One approach would be to have a very simple Message Dialog component that takes a message string as input. You place that on the template of the component and it will get a local name (shows a #messageDialog on the template).

Then in the script, when you hit an issue, you can do

this.message = 'You selected a duplicate item';
this.messageDialog.open();