Metakit / @doeixd/metakit/machine

intent

function · packages/metakit/src/can.ts:60

function intent<
  Arm extends {
    readonly _tag: 'Transition'
    readonly name: string
    readonly when: {
      readonly node: Node
    }
  },
>(
  arm: Arm,
  options?: Expr.ReaderOptions,
): Intent<StateOf<Arm>, Arm['name'], Arm>

The intent of arm, taken from a machine's transitions: its message is tagged with the arm's name, and its can checks the guard against the values you give it, using options for custom operation implementations and the rewrite policy. It checks no membership: for a machine built with attach or compose, take the arm from that machine (attached.transitions['cart/Add']), since a message built from the child's arm carries the child's tag and dispatch refuses it as an unknown message.