# VariantTransitions
Source: https://docs.maelstrom-ai.co/dev/reference/client/interfaces/varianttransitions/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

Defined in: [packages/client/src/lib/command-processor/action-manager.ts:113](https://github.com/maelstrom-co/maelstrom/blob/89a8f5e9d10cedcf0b30376d7846113f06f26120/packages/client/src/lib/command-processor/action-manager.ts#L113)

Lets [ActionManager.executeActions](https://docs.maelstrom-ai.co/dev/reference/client/classes/actionmanager/#executeactions) resolve each Action against the Instance’s current Variant and apply the Action’s `transitionsTo`.

[CommandProcessor](https://docs.maelstrom-ai.co/dev/reference/client/classes/commandprocessor/) builds one from its store and Vessel registry.

## Methods

### apply()

> **apply**(`instanceId`, `expected`, `next`): `boolean`

Defined in: [packages/client/src/lib/command-processor/action-manager.ts:135](https://github.com/maelstrom-co/maelstrom/blob/89a8f5e9d10cedcf0b30376d7846113f06f26120/packages/client/src/lib/command-processor/action-manager.ts#L135)

Compare-and-set: moves the Instance to `next` only while its Variant is still `expected`.

#### Parameters

##### instanceId

`InstanceId`

The Instance to transition.

##### expected

`VariantName`

The Variant the Action started from.

##### next

`VariantName`

The Variant the Action transitions to.

#### Returns

`boolean`

Whether the transition applied. `false` means a newer write won.

* * *

### resolve()

> **resolve**(`instanceId`, `action`): [`ActionVariantResolution`](https://docs.maelstrom-ai.co/dev/reference/client/type-aliases/actionvariantresolution/)

Defined in: [packages/client/src/lib/command-processor/action-manager.ts:125](https://github.com/maelstrom-co/maelstrom/blob/89a8f5e9d10cedcf0b30376d7846113f06f26120/packages/client/src/lib/command-processor/action-manager.ts#L125)

Reads the Instance’s current Variant and the named Action’s declaration on it. Called at the Action’s turn, and again once its handler succeeds when the Action declares a transition, since the Vessel can be redefined while the handler runs.

#### Parameters

##### instanceId

`InstanceId`

The Instance the Action targets.

##### action

`ActionName`

The Action about to run.

#### Returns

[`ActionVariantResolution`](https://docs.maelstrom-ai.co/dev/reference/client/type-aliases/actionvariantresolution/)

The Variant and declared transition, or why the Action is unavailable.
