Usage

Add an interaction budget

This type is used by 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 });
});

Type declaration

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

Members 14

NameTypeRequiredDescription
toStayWithin(budget: CostBudget) => voidYesThrows, naming every counter over budget, when the cost exceeds it.
recordsAppliednumberYesRecords of the batches applied, the UI thread's prop writes included.
propWritesnumberYes—
wastedPropWritesnumberYesProp writes of the value the view already had.
layoutPassesnumberYesLayouts that computed at least one node.
wastedLayoutPassesnumberYesLayout passes after which no box changed.
nodesLaidOutnumberYesNodes the engine computed rather than took from its cache.
nodesFramednumberYesBoxes the renderer took from a pass.
wastedFramesnumberYesBoxes taken unchanged.
measureCallsnumberYesLeaves measured: each one a miss of the engine's measure cache.
wastedMeasuresnumberYesMeasures that answered what the leaf measured before it was marked dirty.
uiEntriesnumberYesCalls into the UI-thread kernel: operations received, events, frames.
wastedUiEntriesnumberYesEvents the UI-thread kernel had no handler for.
viewsCreatednumberYesViews made with a native view: a flattened node has none.
toStayWithin — method signatures

Signatures

ts
(budget: CostBudget): void

Parameters

NameTypeRequiredDescription
budgetPartial<Counts>Yes—

Returns

void

Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.