@stardust-ui/state

A set of utils to create framework agnostic and reusable state managers

Usage no npm install needed!

<script type="module">
  import stardustUiState from 'https://cdn.skypack.dev/@stardust-ui/state';
</script>

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.