Skip to content
LogoLogo

Predicates

A predicate holds reusable condition logic that reads the current state of your application. Each predicate is a pure function. It takes a state snapshot, and that snapshot holds the responses, the fields, the browser context, and optional arguments.

Use the state snapshot

Each predicate takes a StateSnapshot object with these properties:

interface StateSnapshot {
  client: Picked // The Picked client.
  responses?: Array<{
    // Every response from the user.
    fieldId: string
    value: FieldValue | undefined
  }>
  args?: unknown[]
  fields?: Field[] // Every registered field.
  location?: Location // The browser location: URL, pathname, search, and more.
  document?: Document // The browser document object.
  sessionStorage?: Storage // The browser sessionStorage API.
  localStorage?: Storage // The browser localStorage API.
}