Sha256: 7d9c3b14c90f22d58b46179dcec569313d6f20835fb767c40a1a7549aee465ae
Contents?: true
Size: 569 Bytes
Versions: 8
Compression:
Stored size: 569 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: Element, condition: () => boolean, body: () => void) => { 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