Metakit / @doeixd/metakit/machine

From

interface · packages/metakit/src/machinePhaseTypes.ts:178

interface From<
  S extends Schema.Top,
  I extends Schema.Top,
  P,
  L extends string,
> {
  readonly input: <Next extends Schema.Top>(input: Next) => From<S, Next, P, L>
  readonly to: <N extends PhaseName<P>>(
    target: Phase<S['Type'], N, Held<P, N>>,
    ...apply: Gives<P, L, N> extends 'required'
      ? [
          apply: (
            env: PhaseEnv<S['Type'], I['Type'], Held<P, L>>,
          ) => Entry<S['Type'], I['Type'], P, L, N>,
        ]
      : [
          apply?: (
            env: PhaseEnv<S['Type'], I['Type'], Held<P, L>>,
          ) => Entry<S['Type'], I['Type'], P, L, N>,
        ]
  ) => PhaseTransition<S['Type'], I['Type'], PhaseName<P>, ServicesOf<I>>
  readonly choose: (
    alternatives: (
      env: PhaseEnv<S['Type'], I['Type'], Held<P, L>>,
    ) => Alternatives<S['Type'], I['Type'], P, L>,
  ) => PhaseTransition<S['Type'], I['Type'], PhaseName<P>, ServicesOf<I>>
}

The transitions that leave the phases L given to from.

Members

From.input

property · packages/metakit/src/machinePhaseTypes.ts:180

readonly input: <Next extends Schema.Top>(input: Next) => From<S, Next, P, L>

The same phases, for a message that carries input.

From.to

property · packages/metakit/src/machinePhaseTypes.ts:187

readonly to: <N extends PhaseName<P>>(
  target: Phase<S['Type'], N, Held<P, N>>,
  ...apply: Gives<P, L, N> extends 'required'
    ? [
        apply: (
          env: PhaseEnv<S['Type'], I['Type'], Held<P, L>>,
        ) => Entry<S['Type'], I['Type'], P, L, N>,
      ]
    : [
        apply?: (
          env: PhaseEnv<S['Type'], I['Type'], Held<P, L>>,
        ) => Entry<S['Type'], I['Type'], P, L, N>,
      ]
) => PhaseTransition<S['Type'], I['Type'], PhaseName<P>, ServicesOf<I>>

The transition into target, with what apply gives besides the phase: writes, and the fields of a variant that has any, as with. A transition from target alone to itself that gives no with writes no phase: the variant stays as it is.

From.choose

property · packages/metakit/src/machinePhaseTypes.ts:206

readonly choose: (
  alternatives: (
    env: PhaseEnv<S['Type'], I['Type'], Held<P, L>>,
  ) => Alternatives<S['Type'], I['Type'], P, L>,
) => PhaseTransition<S['Type'], I['Type'], PhaseName<P>, ServicesOf<I>>

One transition with several outcomes: the first alternative whose when holds is taken, so alternatives are disjoint by their order. Without an otherwise, the message is refused where no condition holds.