Let's say we have this very common code:
{#await myPromise then myResult}
<DataTable rows={myResult.rows}/>
{\await}
Suppose you need to update the returned rows at a later moment, or any other data from the promise's result.
The question: is there any simple way to store a reference to myResult or to their properties in order to be handled in the script block? I'm using two workarounds, but there must be a simpler way.
Workaround #1: don't use an await block at all. Use the fetch().then() syntax and handle it all at the script block. Contrived, but it works.
Dirty workaround #2: create a stupid function that takes a lambda an returns always an empty string. Call that stupid function like this:
{#await myPromise then myResult}
{myStupidFunction(() => { rowsInScript = myResult.rows; })}
<DataTable rows={myResult.rows}/>
{\await}
Since the function returns nothing, it doesn't affect the HTML section.
I hope there's a more elegant way to achieve this, nevertheless.