@genshi/middlewares
Version:
A simple, composable and effective JavaScript state management library
23 lines (21 loc) • 584 B
TypeScript
import { ActionMiddleware } from '@genshi/core';
/**
* The `immer` middleware allows you to use the {@link https://immerjs.github.io/immer/docs/introduction | Immer}
* library to create immutable state updates.
*
* ```ts
* import { Store } from "@genshi/core";
* import { immer } from "@genshi/middlewares/immer";
*
* const store = new Store(
* { count: 0 },
* { middlewares: { action: [immer()] } }
* );
*
* const action = store.action("increment", ({ state }) => {
* state.count++;
* return state;
* });
* ```
*/
export declare const immer: ActionMiddleware;