On this page
Tasks
startTask() and task() can be used to mark all async operations
during store initialization.
import { task } from 'nanostores'
onMount($post, () => { task(async () => { $post.set(await loadPost()) })})You can wait for all ongoing tasks end in tests or SSR with await allTasks().
import { allTasks } from 'nanostores'
$post.listen(() => {}) // Move store to active mode to start data loadingawait allTasks()
const html = ReactDOMServer.renderToString(<App />)Imported from the Nano Stores README for version 1.5.5. Improve this page there.