Utilisation

Add an interaction budget

Ce type est utilisé par 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 });
});

Déclaration du type

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

Membres 14

NomTypeRequisDescription
toStayWithin(budget: CostBudget) => voidOuiThrows, naming every counter over budget, when the cost exceeds it.
recordsAppliednumberOuiRecords of the batches applied, the UI thread's prop writes included.
propWritesnumberOui—
wastedPropWritesnumberOuiProp writes of the value the view already had.
layoutPassesnumberOuiLayouts that computed at least one node.
wastedLayoutPassesnumberOuiLayout passes after which no box changed.
nodesLaidOutnumberOuiNodes the engine computed rather than took from its cache.
nodesFramednumberOuiBoxes the renderer took from a pass.
wastedFramesnumberOuiBoxes taken unchanged.
measureCallsnumberOuiLeaves measured: each one a miss of the engine's measure cache.
wastedMeasuresnumberOuiMeasures that answered what the leaf measured before it was marked dirty.
uiEntriesnumberOuiCalls into the UI-thread kernel: operations received, events, frames.
wastedUiEntriesnumberOuiEvents the UI-thread kernel had no handler for.
viewsCreatednumberOuiViews made with a native view: a flattened node has none.
toStayWithin — signatures de méthode

Signatures

ts
(budget: CostBudget): void

Paramètres

NomTypeRequisDescription
budgetPartial<Counts>Oui—

Retourne

void

Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.