qat

What the framework does

LoadState, ErrorFallback, IslandMarker, Inspector. They are copied into your app’s ui/ by qatjs add framework: the code is yours to edit.

Example

Leyla Məmmədova, customer since 2021.

island Cart, 612 B

Tandir bread × 2

Example.qx42 lines, 1 reactive nameOpen in the playground
import Button from './ui/button/button.qx'
import { ErrorFallback, IslandMarker, LoadState, type Loadable } from './ui/framework/framework.qx'

const failed: Loadable<{ name: string }> = {
  loading: () => false,
  data: () => undefined,
  error: () => new Error('api.user(42) answered 503 after 2 tries.'),
  reload: () => {},
}

export default function Example() {
  let reloads = state(0)
  let ready: Loadable<{ name: string; since: number }> = {
    loading: () => reloads % 2 === 1,
    data: () => ({ name: 'Leyla Məmmədova', since: 2021 }),
    error: () => undefined,
    reload: () => reloads++,
  }
  return (
    <div class="example-grid">
      <LoadState of={ready} name="user">
        {(u) => (
          <p>
            {u.name}, customer since {u.since}.{' '}
            <Button size="sm" on:click={() => reloads++}>
              Refresh
            </Button>
          </p>
        )}
      </LoadState>
      <LoadState of={failed} name="user" errorTitle="Couldn’t load the account">
        {(u) => <p>{u.name}</p>}
      </LoadState>
      <ErrorFallback error={new Error('cart() is null')} where="src/Checkout.qx:41">
        The rest keeps working. Your cart is saved.
      </ErrorFallback>
      <IslandMarker name="Cart" bytes={612}>
        <p>Tandir bread × 2</p>
      </IslandMarker>
    </div>
  )
}
reloads state

Add it

shell1 line
npx qatjs add framework

LoadState

As a custom element: <ui-load-state>.

LoadState: props
PropTypeAttribute
ofLoadable<T>property only
namestringyes
labelstringyes
errorTitleQatNodeproperty only
retryLabelstringyes

ErrorFallback

As a custom element: <ui-error-fallback>.

ErrorFallback: props
PropTypeAttribute
errorunknownproperty only
titleQatNodeproperty only
wherestringyes
retry() => voidproperty only
retryLabelstringyes

IslandMarker

As a custom element: <ui-island-marker>.

IslandMarker: props
PropTypeAttribute
namestringyes
bytesnumberyes

Inspector

The devtools panel's chrome: tabs, a count, the graph as rows (WAI-APG tabs and a list to choose from). As a custom element: <ui-inspector>.

Inspector: props
PropTypeAttribute
tabsstring[]property only
tabstringyes
summarystringyes
nodesInspectorNode[]property only
selectedstringyes
labelstringyes
Inspector: events
EventDetail
on:update:tabCustomEvent<string>
on:update:selectedCustomEvent<string>