forEachCheckpoint
The forEachCheckpoint
method takes a function that it will then call for each Checkpoint in a specified Checkpoints
object.
forEachCheckpoint(checkpointCallback: CheckpointCallback): void
Type | Description | |
---|---|---|
checkpointCallback | CheckpointCallback | The function that should be called for every Checkpoint. |
returns | void | 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.
import {createCheckpoints, createStore} from 'tinybase';
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'
Since
v1.0.0