TinyBase logoTinyBase


The schedule method allows you to queue up a series of asynchronous actions that must run in sequence during persistence.

schedule(actions: Promise<any>[]): Promise<Persister>

A reference to the Persister object.

For example, a database Persister may need to ensure that multiple asynchronous tasks to check and update the database schema are completed before data is written to it. Therefore it's most likely you will be using this method inside your setPersisted implementation.

Call this method to add a single asynchronous action, or a sequence of them in one call. This will also start to run the first task in the queue (which once complete will then run the next, and so on), and so this method itself is also asynchronous and returns a promise of the Persister.


This example creates a custom Persister object against a newly-created Store and then sequences two tasks in order to update its data on a hypothetical remote system.

const store = createStore();
const persister = createCustomPersister(
  async () => {
    // getPersisted
    return await getDataFromRemoteSystem();
  async (getContent) => {
    // setPersisted
    await persister.schedule(
      async () => await checkRemoteSystemIsReady(),
      async () => await sendDataToRemoteSystem(getContent()),
  (listener) => setInterval(listener, 1000),
  (interval) => clearInterval(interval),