Empty means keep loading
An empty array is a finished result. Stop the skeleton and explain the empty state.
Reserve space, explain progress, and make the next action clear.
Build an asynchronous request region that distinguishes loading, ready, empty, failed and stale data. Retry stays available, and a failed refresh can keep the last successful result visible.
Use a Skeleton when you know the shape of the incoming content. Use measured progress for uploads or exports with known totals. Reserve a full-screen blocker for work that really blocks the whole screen.
Real BluKavantUI components, with a small application controller. Data and save responses are simulated in this page; reload resets the example.
Loading the interactive recipe…
Reserves space during the first request.
Explains a successful empty result or a failed initial request.
Announces the result and exposes retry without stealing focus.
Keep the last accepted rows separately from loading and error state. Null means not loaded; [] means a successful empty response.
Show placeholders only in the loading region. Put one live status outside its aria-busy subtree; decorative skeleton shapes should not be individually announced.
Use an AbortController and request sequence. Cancellation reduces work; the sequence guard also protects against services that finish despite cancellation.
A failed first load shows an error and retry. A failed refresh retains the previous rows with a clear stale notice. Retry uses the same query context.
| State / contract | Implementation |
|---|---|
| Load port | load(signal: AbortSignal): Promise<RequestRow[]>. Reject for failure; return [] for a successful empty result. |
| Request identity | Increment a sequence number on every request; only the active sequence may update content, status or aria-busy. |
| Busy region | aria-busy=true while pending, then false for every settled active outcome. |
| Accepted snapshot | Keep rows from the last success. A refresh error does not silently label old data as current. |
Call mount(host, loadRequests). Wire loadRequests to your API and pass the AbortSignal into fetch. Check response.ok before parsing. The returned refresh() starts a request; destroy() aborts pending work and destroys mounted components. This demo uses a deterministic delayed adapter so you can exercise every outcome.
Install Community and the required Pro add-on for Grid or Kanban recipes, import @blukavantui/community/styles.css, and use a connected host element. The companion CSS styles the surrounding fields, navigation and status messages.
Keep the recipe and shared.ts together; TypeScript resolves the recipe’s ./shared.js import. Add class="recipe-demo" to your host. Supply your records and backend callback as the mount arguments. The downloads use Community 1.0.0 and Pro 1.0.0 imports; the live demo retains its previously verified SDK 0.9.0 runtime.
import { createSkeleton } from '@blukavantui/community/skeleton';
import { createEmptyState } from '@blukavantui/community/empty-state';
import { node, button, status } from './shared.js';
export interface RequestRow { id: string; title: string }
export function mount(host: HTMLElement, load: (signal: AbortSignal) => Promise<RequestRow[]>) {
const retry = button('Load requests', () => { void refresh(); });
const region = node('section', '', 'recipe-load-region'); region.setAttribute('aria-label', 'Requests');
host.append(retry, region); const message = status(host);
let rows: RequestRow[] | null = null, serial = 0, disposed = false, abort: AbortController | undefined;
let view: { destroy(): void } | undefined;
function clear() { view?.destroy(); view = undefined; region.replaceChildren(); }
function showRows() {
clear(); const list = node('ul', '', 'recipe-loaded-list');
for (const row of rows || []) list.append(node('li', `${row.id} · ${row.title}`));
region.append(list);
}
async function refresh() {
abort?.abort(); abort = new AbortController(); const request = ++serial;
retry.textContent = 'Restart request'; region.setAttribute('aria-busy', 'true'); message.textContent = 'Loading requests…';
if (rows === null) {
clear(); const placeholder = node('div'); placeholder.setAttribute('aria-hidden', 'true'); region.append(placeholder);
view = createSkeleton(placeholder, { Shape: 'Rectangle', Width: '100%', Height: '160px' });
}
try {
const result = await load(abort.signal);
if (disposed || request !== serial) return; rows = result; clear();
if (rows.length) showRows();
else view = createEmptyState(region, { Title: 'No requests yet', Description: 'The request completed successfully. Your queue is empty.', Kind: 'Empty' });
message.textContent = rows.length ? `${rows.length} requests loaded.` : 'No requests to display.';
} catch {
if (disposed || request !== serial) return;
if (rows?.length) { showRows(); message.textContent = 'Refresh failed. Showing the previous result; try again.'; }
else {
clear(); view = createEmptyState(region, { Title: 'Requests could not be loaded', Description: 'Choose Retry requests to try again.', Kind: 'Error' });
message.textContent = 'Request failed. You can retry.';
}
} finally {
if (!disposed && request === serial) { region.setAttribute('aria-busy', 'false'); retry.textContent = 'Retry requests'; }
}
}
message.textContent = 'Choose an outcome above, then load the requests.';
return { refresh, destroy() { disposed = true; serial++; abort?.abort(); clear(); host.replaceChildren(); } };
}
Use Skeleton from BluKavantUi_Community_Core and EmptyState from BluKavantUi_Community_Feedback in either edition. Compose them with native Containers, an If and a Retry button. These Blocks provide presentation; the consumer owns the data-fetch state.
| Binding / handler | Implementation |
|---|---|
| Screen variables | IsLoading, HasLoaded, HasError, ActiveRequestNumber, ErrorMessage and the last accepted Rows list. Keep HasLoaded separate from Rows.Empty. |
| Start load | Increment ActiveRequestNumber and capture it in the handler. Set IsLoading=True and HasError=False, then call your authorized data action with the current filters. |
| Accept response | Only apply it if the captured number still equals ActiveRequestNumber. Assign Rows, HasLoaded=True and IsLoading=False; empty Rows is a valid result. |
| Handle failure | For the active request, set HasError=True and IsLoading=False. Preserve previously accepted Rows. Offer Retry with the current query values. |
| Presentation | Use Skeleton before the first result, EmptyState for empty/error content, and a visible stale notice beside existing rows after a refresh failure. Add aria-busy to the region and one external role=status message. |
Add these native Blocks to your consumer Screen, bind the listed events and connect your application actions. The interactive example above runs the web implementation.
Open the full native Skeleton API →An empty array is a finished result. Stop the skeleton and explain the empty state.
Two fetches can finish out of order. Guard success, failure and finally paths with the same request ID.
Transient notifications can disappear before retry is possible. Keep an actionable message with the affected region.
Use the linked component accessibility notes when reviewing focus, keyboard behavior and status announcements in your implementation.