UNPKG

react-constore

Version:

Lightweight and efficient state management for React with TypeScript support

9 lines (7 loc) 254 B
import type { StoreAPI } from "./types"; export const applyMiddleware = <T extends object>( store: StoreAPI<T>, ...middlewares: ((store: StoreAPI<T>) => StoreAPI<T>)[] ): StoreAPI<T> => { return middlewares.reduce((acc, mw) => mw(acc), store); };