I have an application using 4.22 of the Esri JavaScript API. It references several layers from different sources. When one of these layers an outside ArcGIS Online Organization changes or is unavailable, for whatever reason, the API presents the user with the ArcGIS Online sign in dialog. It must assume the layer it is looking for is secured and maybe it can reach it by signing in. This makes no sense to my users and I would like to disable the dialog or cancel the dialog when it opens. That way the layer will fail and notify the user it is not available. However, I can't find a way in the Identity Manager to do this. The closest I can find is the Identity Manager has a dialog-create event. I can create a handler that catches the on dialog create event. But the only thing I can do at that point is set the visibility of the dialog to false. That doesn't actually cancel it. The layer is still waiting for input from the user and never fails. Is another way to disable, cancel, or suppress the dialog?
The following works in 4.24. As far as I can tell, it should also work in 4.22, but I haven't tested...
identityManager.on("dialog-create", function() {
identityManager.dialog.visible = false;
window.setTimeout(function() {
identityManager.dialog.content.emit("cancel", {});
}, 250);
});