TinyBase logoTinyBase β

createGoForwardCallback

The createGoForwardCallback function returns a callback function that, when called, moves the Checkpoints object forward to the next checkpoint.

createGoForwardCallback(checkpointsOrCheckpointsId?: MaybeGetter<undefined | CheckpointsOrCheckpointsId>): () => void
TypeDescription
checkpointsOrCheckpointsId?MaybeGetter<undefined | CheckpointsOrCheckpointsId>

The Checkpoints object to use, or its Id.

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 {createGoForwardCallback} from 'tinybase/ui-svelte';

  let {checkpoints} = $props();

  const goForward = createGoForwardCallback(checkpoints);
  goForward();
</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