isPending
Returns whether the reactive reads inside fn depend on an in-flight value change that has not been revealed.
Import
import { isPending } from "solid-js";Type signature
function isPending(fn: () => any): boolean;Parameters
fn
- Type:
() => any
Expression to probe. Read the values in question inside it.
Return value
true while a read inside fn depends on a change that has not committed yet.
Examples
Dim stale results while a new answer loads
const [query, setQuery] = createSignal("");const results = createMemo(() => searchProducts(query()));
<ul class={{ stale: isPending(results) }}> <For each={results()}>{(product) => <li>{product.name}</li>}</For></ul>;Caveats
- Reports on updates to a value that exists. Before a first value, the read inside
fnfollows the surroundingLoadingpath. - A bare
refresh()does not flipisPending; pair it withaffects()to make the re-ask visible.