TinyBase logoTinyBase

createCheckpoints

The createCheckpoints function creates a Checkpoints object, and is the main entry point into the checkpoints module.

createCheckpoints(store: Store): Checkpoints
TypeDescription
storeStore

The Store for which to set Checkpoints.

returnsCheckpoints

A reference to the new Checkpoints object.

A given Store can only have one Checkpoints object associated with it. If you call this function twice on the same Store, your second call will return a reference to the Checkpoints object created by the first.

Examples

This example creates a Checkpoints object.

import {createCheckpoints, createStore} from 'tinybase';

const store = createStore();
const checkpoints = createCheckpoints(store);
console.log(checkpoints.getCheckpointIds());
// -> [[], '0', []]

This example creates a Checkpoints object, and calls the method a second time for the same Store to return the same object.

import {createCheckpoints, createStore} from 'tinybase';

const store = createStore();
const checkpoints1 = createCheckpoints(store);
const checkpoints2 = createCheckpoints(store);
console.log(checkpoints1 === checkpoints2);
// -> true

Since

v1.0.0