Lost Lily/Grid ToolkitDocs 1.0
Table of Contents

Batch actions on one board

When to use

Use GridBatchAction when several dependent changes on one board must either all commit or all leave state unchanged.

Before you start

Start with one ready board state and actions that already succeed independently.

Every step must be expressible through an action or public GridActionPlanBuilder operation. Keep all participant states alive and do not apply unrelated actions between plan and commit.

Procedure

For one board, use GridBatchAction:

Excerpt — preview and apply one atomic batch. Tested using public APIs.

public static BatchMutationResult ApplyAtomicBatch()
{
    using GridBoardState state = CreateProgrammaticBoard();
    GridBatchAction batch = new(new IGridAction[]
    {
        GridActions.AddCell(new SquareGridCoordinate(4, 0)),
        GridActions.AddCell(new SquareGridCoordinate(4, 1))
    });

    GridActionResult result = GridActionRunner.Apply(state, batch);
    return new BatchMutationResult(
        result.Success,
        state.ContainsCell(new SquareGridCoordinate(4, 0)),
        state.ContainsCell(new SquareGridCoordinate(4, 1)),
        state.Revision);
}

GridBatchAction has one board owner. When a transaction must coordinate two or more boards, use Create multi-board operations. That workflow declares every participant before planning and gives each board its own mutation and event builder.

Result

The batch adds both cells and advances the board from revision 0 to 1. If any child action is rejected, neither cell is added and the revision remains unchanged. See the successful outcome table.

Troubleshooting

  • One child action is rejected: inspect that child's diagnostics; the entire batch remains unapplied.
  • A later action depends on an earlier result: keep the actions in dependency order inside the same batch.
  • The transaction spans several boards: use the multi-board operation workflow instead of applying one batch per board.