TinyBase logoTinyBase

Middleware

A Middleware object lets you intercept and validate writes to a Store.

This is useful for enforcing business rules, data validation, or transformation logic before data is persisted in the Store.

Create a Middleware object easily with the createMiddleware function.

Example

This example shows a very simple lifecycle of a Middleware object: from creation, to getting the Store reference, and then destroying it.

import {createMiddleware, createStore} from 'tinybase';

const store = createStore();
const middleware = createMiddleware(store);

console.log(middleware.getStore() == store);
// -> true

middleware.destroy();

Since

v8.0.0

Getter methods

Configuration methods

Lifecycle methods