# make-zustand

> state management library

Latest version **0.0.1** (published 2019-08-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install make-zustand
pnpm add make-zustand
yarn add make-zustand
bun add make-zustand
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-08-06 |
| First published | 2019-08-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | richard soderman |
| Maintainers | richie_south |

## Links

- npm: https://www.npmjs.com/package/make-zustand
- Repository: https://github.com/richie-south/make-state
- Homepage: https://github.com/richie-south/make-state#readme
- Issues: https://github.com/richie-south/make-state/issues
- npm.io page: https://npm.io/package/make-zustand

## Recent versions

- 0.0.1 (latest) — 2019-08-06

## README

The idea is to split your state into multible smaller stores instead of a large one.

# make-zustand

state management library

install `npm i make-zustand`

**basic example**
```javascript
const settingsStore = makeStore({
  name: '',
})

const [onSettingsChange, setSettingsState, getSettings] = settingsStore

onSettingsChange((settingsState) => {
  console.log(settingsState) // >> { name: 'joanna' }
})

setSettingsState({
  ...getSettings(),
  name: 'joanna'
})

```

**combine example**

```javascript
const settingsStore = makeStore({ name: '' })
const [onSettingsChange, setSettingsState, getSettings] = settingsStore

const todoStore = makeStore([])
const [onTodoChange, setTodoState, getTodo] = todoStore


const settingsTodoStores = combine([
  settingsStore,
  todoStore
], (settings, todo) => ({
  settings,
  todo
}))

const [onSettingsOrTodoChange] = settingsTodoStores

onSettingsOrTodoChange((settingsTodoMap) => {
  console.log(settingsTodoMap) // >> { settings: { name: 'joanna' }, todo: [] }
})

setSettingsState({
  ...getSettings(),
  name: 'joanna'
})

```


# make-zustand-react

react hook bindings for make-zustand

install `npm i make-zustand-react`

**example**
```javascript

import React from 'react'
import { makeStore } from 'make-zustand'
import { useStore } from 'make-zustand-react'

const settingsStore = makeStore({
  name: '',
})

const [, setSettingsState] = settingsStore

export function App() {
  const [settings] = useStore(settingsStore)

  return (
    <div>
      <p>{settings.name}</p>

      <input
        onChange={(e) =>
          setSettingsState({
            ...settings,
            name: e.target.value
          })
        }
      />
    </div>
  )
}

```

---
_Source: https://npm.io/package/make-zustand · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
