Feat Request: Stale-while-revalidate in <await>
Description
This weekend I toyed with a simple auto complete demo. Now that we live in a utopian world with client-side <await>, I wanted to make the implementation as declarative as possible. Example
I leverage <script> and its $signal to update a debounced state value. I pass that debounced value as a parameter to a promise in an <await> so the simulated network request would fire on each debounced value change.
It felt like I was on the right track until I used it. I type, the debounced query waits a tick then the simulated network request fires: So far, so good.
I’m aiming for a UX where the previously settled result stays in the DOM until the promise settles. Once settled, the previously settled results are replaced with recently settled. Unfortunately while the promise is in a pending state, the list of results disappears and is replaced by the <@placeholder> content. It feels super janky.
I tried experimenting with a new state value that holds the previously settled results, but there’s not a clean way for me to set it to the results returned by the await tag.
I also know that this approach would not allow me to abort a pending fetch when the <await> re-renders.
I believe Solid has a paradigm called createResource that allows you to render the previously settled results. https://docs.solidjs.com/reference/basic-reactivity/create-resource#resource
I wonder how Marko could expose a similar behavior. My favorite thing about Marko DX is how most things can be written declaratively, but in this case I was stumped.
Source: marko-js/marko