Utilização

Add an interaction budget

Este tipo é usado por 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 });
});

Declaração do tipo

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

Membros 14

NomeTipoObrigatórioDescrição
toStayWithin(budget: CostBudget) => voidSimThrows, naming every counter over budget, when the cost exceeds it.
recordsAppliednumberSimRecords of the batches applied, the UI thread's prop writes included.
propWritesnumberSim—
wastedPropWritesnumberSimProp writes of the value the view already had.
layoutPassesnumberSimLayouts that computed at least one node.
wastedLayoutPassesnumberSimLayout passes after which no box changed.
nodesLaidOutnumberSimNodes the engine computed rather than took from its cache.
nodesFramednumberSimBoxes the renderer took from a pass.
wastedFramesnumberSimBoxes taken unchanged.
measureCallsnumberSimLeaves measured: each one a miss of the engine's measure cache.
wastedMeasuresnumberSimMeasures that answered what the leaf measured before it was marked dirty.
uiEntriesnumberSimCalls into the UI-thread kernel: operations received, events, frames.
wastedUiEntriesnumberSimEvents the UI-thread kernel had no handler for.
viewsCreatednumberSimViews made with a native view: a flattened node has none.
toStayWithin — assinaturas de método

Assinaturas

ts
(budget: CostBudget): void

Parâmetros

NomeTipoObrigatórioDescrição
budgetPartial<Counts>Sim—

Devolve

void

Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.