vael-ui v0.5.7

Utilities

useAsyncLoading

Tracks every async task you run through it, and stays loading until all of them settle. Use it for one loading state over several requests.

Tracks every in-flight promise you pass to run(). loading stays true until all of them settle, so overlapping calls, or several buttons sharing one instance, don't make the state flicker. Button uses it for loading="auto" when an @click handler returns a promise.

Install

import { useAsyncLoading } from 'vael-ui'

Examples

Parameters

Takes no arguments.

Returns

NameTypeDescription
loadingComputedRef<boolean>true while at least one run() call hasn't settled.
run<T>(fn: () => T | Promise<T>) => Promise<T>Runs fn and counts it as in flight until it settles.