How to know when shapediver-domElements are added following an updateAsync call

As updateAsync refreshes the shapediver-domElements, I need to call a function (that adds special classes to these elements) following each update. I’m unable to accomplish this via async (promises) unless I rely on a setTimeout (I really don’t want to rely on a setTimeout). I’m hoping there’s an easier way before digging into MutationObserver.

Does ShapeDiver provide a method of knowing when the shapediver-domElements have been added to the page?

After digging into MutationObserver, it seems the best overall method of adding custom classes to shapediver-domElements. I can just create an observer and know that my classes will be added without having to use a callback every time the viewer updates shapediver-domElements.

In light of this, the topic title is probably irrelevant.

For my usage scenario (applying a class based on 2D text tags being a number or not), I’m using this to moot my issue:

const config = {childList: true, subtree: true};
const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        if( mutation.addedNodes.length > 0
            && mutation.addedNodes[0].classList.contains("shapediver-domElement-span")
        ) {
            return (
const target = document.querySelector(".shapediver-domElements");
observer.observe(target, config);