#3721·marko

Feat Request: Stale-while-revalidate in <await>

Author: caseycarrollCreated Aug 2, 2026Updated Aug 4, 2026
Labelstype:feature

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.

Playground Link: https://markojs.com/playground#djIfiwgAAAAAAAATXZAxT8MwEIX_ysliSKWqZmBAJQkMLGyA2BoG17m2Fq4d7DNQtf3vXJxQtWzn8733vbvFXnSKNmIujGvxZ7ZV4cOLqdDeETrifmmR5GfCsKsa0Yi6caVxXaLGAdCuQ-5GVEFv-JdbX8omnFdZALLuW42LpMhoYCcgs0Wf6OkRKnDJ2jv26wktLn1yGtuXC1TUwXSUbc6VEelteBbFBKoa9nBpwDM5wnEKN9fXk15_Fc3aKTvzTi19IJ4YpNpy_D-3E4QlpTzRTyuouHMaVgwi4x2skV4xJkuxyLgJ7HuU-laGwOE3PAe_NRGLImD09gsz8Sz92J7CLafMMQNSCg4WjVhyrkZMgau0HgtEstiI934SYLYyljAU-ei9cy5mxmmbWvzLxLZH3obCLt-xzOkOYch9qM52uLzhpB4o5cqHcfwAflWNyvGX_62pr_ZD91hKfo06ycIBKTNzqB86qzRuvG0xjJNSglWR-sPwei2MBLi_H9T_JKXsdxHH91-K0YSJvgIAAA