Verwendung

Add an interaction budget

Dieser Typ wird verwendet von tests.costOf

tsx
import { Pressable, Text, signal } from 'kuito';
import { costOf, press, render, screen, test } from 'kuito/tests';

function Like() {
  const liked = signal(false);
  return (
    <Pressable onPress={() => (liked.value = !liked.value)} opacity={liked.value ? 1 : 0.6}>
      <Text>Like</Text>
    </Pressable>
  );
}

test('a like lays nothing out', async () => {
  await render(<Like />);

  const cost = await costOf(() => press(screen.getByText('Like')));

  cost.toStayWithin({ layoutPasses: 0, measureCalls: 0, viewsCreated: 0 });
});

Typdeklaration

ts
export interface Cost extends Readonly<Counts> {
  /** Throws, naming every counter over `budget`, when the cost exceeds it. */
  toStayWithin(budget: CostBudget): void;
}

Mitglieder 14

NameTypErforderlichBeschreibung
toStayWithin(budget: CostBudget) => voidJaThrows, naming every counter over budget, when the cost exceeds it.
recordsAppliednumberJaRecords of the batches applied, the UI thread's prop writes included.
propWritesnumberJa—
wastedPropWritesnumberJaProp writes of the value the view already had.
layoutPassesnumberJaLayouts that computed at least one node.
wastedLayoutPassesnumberJaLayout passes after which no box changed.
nodesLaidOutnumberJaNodes the engine computed rather than took from its cache.
nodesFramednumberJaBoxes the renderer took from a pass.
wastedFramesnumberJaBoxes taken unchanged.
measureCallsnumberJaLeaves measured: each one a miss of the engine's measure cache.
wastedMeasuresnumberJaMeasures that answered what the leaf measured before it was marked dirty.
uiEntriesnumberJaCalls into the UI-thread kernel: operations received, events, frames.
wastedUiEntriesnumberJaEvents the UI-thread kernel had no handler for.
viewsCreatednumberJaViews made with a native view: a flattened node has none.
toStayWithin — Methodensignaturen

Signaturen

ts
(budget: CostBudget): void

Parameter

NameTypErforderlichBeschreibung
budgetPartial<Counts>Ja—

Rückgabe

void

Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.