TinyBase logoTinyBase

forEachCheckpoint

The forEachCheckpoint method takes a function that it will then call for each Checkpoint in a specified Checkpoints object.

forEachCheckpoint(checkpointCallback: CheckpointCallback): void
TypeDescription
checkpointCallbackCheckpointCallback

The function that should be called for every Checkpoint.

returnsvoid

This has no return value.

This method is useful for iterating over the structure of the Checkpoints object in a functional style. The checkpointCallback parameter is a CheckpointCallback function that will be called with the Id of each Checkpoint.

Example

This example iterates over each Checkpoint in a Checkpoints object.

const store = createStore().setTables({pets: {fido: {sold: false}}});
const checkpoints = createCheckpoints(store);
store.setCell('pets', 'fido', 'sold', true);
checkpoints.addCheckpoint('sale');

checkpoints.forEachCheckpoint((checkpointId, label) => {
  console.log(`${checkpointId}:${label}`);
});
// -> '0:'
// -> '1:sale'