Thank you Robert and Arne.
I provide the original example with applied workarounds from you both and some additions. To get it to work in all use cases with v4.8+, I had to do the following (please note the two "workaround"-comments):
require([
"esri/views/MapView",
"esri/Map",
"esri/layers/MapImageLayer",
"esri/core/watchUtils"
], function(
MapView, Map, MapImageLayer, watchUtils
) {
var mapConfigs = [
{},
{},
{}
];
var maps = mapConfigs.map(function(mapConfig) {
var map = new Map(mapConfig);
map.add(new MapImageLayer({
url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer'
}));
return map;
});
var view = new MapView({
map: maps[0],
container: "viewDiv"
});
view.when(function() {
view.goTo(view.extent.clone());
});
document.querySelector(".btns").addEventListener("click", function(
event) {
var id = event.target.getAttribute("data-id");
if (id) {
var map = maps[id];
view.map = map;
watchUtils.whenTrue(view, "ready", function() {
watchUtils.whenTrueOnce(view, "stationary", function() {
view.goTo(view.extent.clone());
});
});
var nodes = document.querySelectorAll(".btn-switch");
for (var idx = 0; idx < nodes.length; idx++) {
var node = nodes[idx];
var mapIndex = node.getAttribute("data-id");
if (mapIndex === id) {
node.classList.add("active-map");
} else {
node.classList.remove("active-map");
}
}
}
});
});
If I go back to 4.7 - i can inactivate the two commented workaround sections and see the mapView loaded both initially and when switching between the different map-objects. Using 4.8 or later, I find that I need the first workaround section to trigger the initial data-fetching for the default map object. The second workaround section is needed for when I swap the map object. Note that it is a nested watcher, it wasn't sufficient with just 'stationary' or 'ready' - but a combination of both..
Its an acceptable workaround, even if the user experience differ somewhat (was a smoother and somewhat faster switch with 4.7).
Thanks again!