Sha256: 132ee2ad8f1e953ca3e7672f9442fce905db5b9fbb43560f8d1306580b4856fd

Contents?: true

Size: 594 Bytes

Versions: 8

Compression:

Stored size: 594 Bytes

Contents

// Waits for condition to return true. If it returns false initially, this function creates a
// MutationObserver that calls body() whenever the contents of the component change.
export const observeMutationsUntilConditionMet = (element, condition, body) => {
    if (condition()) {
        body();
    }
    else {
        const mutationObserver = new MutationObserver(() => {
            if (condition()) {
                body();
                mutationObserver.disconnect();
            }
        });
        mutationObserver.observe(element, { childList: true, subtree: true });
    }
};

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
primer_view_components-0.36.5 app/components/primer/utils.js
openproject-primer_view_components-0.52.2 app/components/primer/utils.js
primer_view_components-0.36.4 app/components/primer/utils.js
openproject-primer_view_components-0.52.1 app/components/primer/utils.js
openproject-primer_view_components-0.52.0 app/components/primer/utils.js
primer_view_components-0.36.3 app/components/primer/utils.js
openproject-primer_view_components-0.51.0 app/components/primer/utils.js
primer_view_components-0.36.2 app/components/primer/utils.js