createGoBackwardCallback
The createGoBackwardCallback function returns a callback function that, when called, moves the Checkpoints object backward to the previous checkpoint.
createGoBackwardCallback(checkpointsOrCheckpointsId?: MaybeGetter<undefined | CheckpointsOrCheckpointsId>): () => void| Type | Description | |
|---|---|---|
checkpointsOrCheckpointsId? | MaybeGetter<undefined | CheckpointsOrCheckpointsId> | The |
| returns | () => void | A callback function. |
Example
This example passes a TinyBase object into a Svelte component and reads the reactive object's current property.
App.svelte
<svelte:options runes={true} />
<script>
import {createGoBackwardCallback} from 'tinybase/ui-svelte';
let {checkpoints} = $props();
const goBackward = createGoBackwardCallback(checkpoints);
goBackward();
</script>
{'done'}
import {flushSync, mount} from 'svelte';
import {createCheckpoints, createStore} from 'tinybase';
import App from './App.svelte';
const store = createStore()
.setTables({
pets: {
fido: {species: 'dog', color: 'brown', sold: false, next: 'felix'},
felix: {species: 'cat', color: 'black', sold: true},
},
species: {dog: {price: 5}, cat: {price: 4}},
})
.setValues({open: true, employees: 3});
const checkpoints = createCheckpoints(store);
const app = document.body.appendChild(document.createElement('div'));
flushSync(() => mount(App, {target: app, props: {checkpoints}}));
console.log(app.textContent);
// -> 'done'
Since
v8.1.0