ObservableFramework: run function after DOM element has been returned from module and rendered

I have a page source which imports a helper function get_node() from a custom module. The function returns htl.html`<div id="foo">...</div>` but only after some calculation. In the source page, I assign const the_node = get_node(). How do I make subsequent code, e. g. the_node.addEventListener() wait until the element is returned (as, e.g., display(the_node) properly does?


The purpose at hand is to create a Dygraph foo and reactively display its date range foo.xAxisRange()

Assuming that get_node() is asynchronous, you can simply await the returned promise:

const the_node = await get_node()
1 Like