@stardust-ui/state
TypeScript icon, indicating that this package has built-in type declarations

0.40.0 • Public • Published

@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.

Readme

Keywords

none

Package Sidebar

Install

npm i @stardust-ui/state

Weekly Downloads

8

Version

0.40.0

License

MIT

Unpacked Size

17.3 kB

Total Files

18

Last publish

Collaborators

  • alinais
  • davezuko
  • layershifter
  • levithomason
  • miroslavstastny
  • mnajdova