TinyBase logoTinyBase β

stopAutoPersisting

The stopAutoPersist method is a convenience method that stops both automatic loading and saving of the Store data.

stopAutoPersisting(stopSaveFirst?: boolean): Promise<LocalPersister>
TypeDescription
stopSaveFirst?boolean

Whether to stop saving before loading, defaulting to false.

returnsPromise<LocalPersister>

A Promise containing a reference to the Persister object.

This simply runs the stopAutoLoad and stopAutoSave methods in sequence, and returns a Promise that resolves when both have completed.

If for some reason you want to stop saving before you stop loading, pass true as the second parameter.

Example

automatically loading and saving.

import {createStore} from 'tinybase';
import {createSessionPersister} from 'tinybase/persisters/persister-browser';

const persister = createSessionPersister(createStore(), 'pets');

await persister.startAutoPersisting();
console.log(persister.isAutoSaving());
// -> true
console.log(persister.isAutoLoading());
// -> true

await persister.stopAutoPersisting();
console.log(persister.isAutoSaving());
// -> false
console.log(persister.isAutoLoading());
// -> false

persister.destroy();

Since

v6.1.0