latest
Reads the freshest in-flight value available inside fn, falling back to the current settled value.
Import
import { latest } from "solid-js";Type signature
function latest<T>(fn: () => T): T;Parameters
fn
- Type:
() => T
Expression to read. In-flight values are returned in place of committed ones.
Return value
The value fn returns when in-flight values are read in place of committed ones.
Examples
const preview = () => latest(user);Caveats
- Use it on controls, not on content. Data read through
latestcan show a new answer before the rest of the update agrees with it. - Before any value exists, the read still suspends like a normal read.