TinyBase logoTinyBase

getStatus

The getStatus method lets you find out if the Persister is currently in the process of loading or saving content.

getStatus(): Status
returnsStatus

A value of type Status indicating whether the Persister is idle, loading, or saving.

It can only be doing one or the other (or neither) at any given time. The Status enum is returned, where 0 means idle, 1 means loading, and 2 means saving.

This method is only likely to be useful for Persister implementations that have asynchronous load or save operations. The status for synchronous persister media (such as browser local or session storage) will switch back to idle before you are able to query it.

Example

This example creates a Persister and queries its status.

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

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

console.log(persister.getStatus());
// -> 0

Since

v5.3.0