@stardust-ui/state
v0.40.0
Published
A set of utils to create framework agnostic and reusable state managers
Downloads
110
Keywords
Readme
@stardust-ui/state
A set of utils to create framework agnostic and reusable state managers.
Installation
NPM
npm install --save @stardust-ui/state
Yarn
yarn add @stardust-ui/state
Usage
import { createManager, ManagerFactory } from "@stardust-ui/state";
type InputState = { value: string };
type InputActions = { change: (value: string) => void };
const createInputManager: ManagerFactory<InputState, InputActions> = config =>
createManager<InputState, InputActions>({
...config,
actions: {
change: (value: string) => () => ({ value })
},
state: { value: "", ...config.state }
});
const manager = createInputManager({ state: { value: "Hello world!" } });
Usage with React
We provide React bindings under @stardust-ui/react-bindings
.