# statefully

> A tiny state container for your javascript apps

Latest version **0.2.0** (published 2018-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install statefully
pnpm add statefully
yarn add statefully
bun add statefully
```

## 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.2.0 |
| Published | 2018-11-27 |
| First published | 2018-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Rahman Fadhil |
| Maintainers | rahmandev |
| Keywords | state, javascript, container, react, zero-dependencies |

## Links

- npm: https://www.npmjs.com/package/statefully
- Repository: https://github.com/rahmanfadhil/statefully
- Homepage: https://github.com/rahmanfadhil/statefully#readme
- Issues: https://github.com/rahmanfadhil/statefully/issues
- npm.io page: https://npm.io/package/statefully

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2018-11-27
- 0.1.9 — 2018-11-27
- 0.1.7 — 2018-11-27
- 0.1.5 — 2018-11-25
- 0.1.4 — 2018-11-25
- 0.1.3 — 2018-11-25
- 0.1.2 — 2018-11-25
- 0.1.1 — 2018-11-24
- 0.1.0 — 2018-11-24
- 0.0.1 — 2018-11-23

## README

# Statefully

![Travis (.org)](https://img.shields.io/travis/rahmanfadhil/statefully.svg) ![size](https://badgen.net/npm/v/statefully) ![size](https://badgen.net/badgesize/normal/https://unpkg.com/statefully@0.1.3/dist/index.js) ![dependencies](https://badgen.net/npm/dependents/statefully)

📦 A tiny state container for your javascript apps

- 💡 **Simple:** Easy to learn & use APIs
- 📦 **Small:** Zero dependencies + 1kb minified size only
- 🔌 **Pluggable:** Use anywhere you want
- 🔒 **Type-Safe:** Great type support with TypeScript & Flow

> ⚠ NOTE: This project is under active development!

---

### 🔧 Installation

**NodeJS**

```sh
# Using npm
npm install statefully

# Using yarn
yarn add statefully
```

**HTML**

```html
<script src="https://unpkg.com/statefully@latest/dist/index.min.js"></script>
```

---

### 📦 Usage

**Create container**

```js
// Using ES Module
import { createContainer } from "statefully";
// Using CommonJS
const { createContainer } = require("statefully");

// Create container with initial value
const store = createContainer({ greeting: "John" });
```

**Get container state**

```js
store.getState(); // { greeting: "John" }
```

**Actions**

```js
// Create action
const setGreeting = store.action((state, { name }) => ({ greeting: name }));

// Call action
setGreeting({ name: "Doe" });

store.getState(); // { greeting: "Doe" }
```

**Subscribe container**

```js
store.subscribe(() => {
  console.log("Store changed: ", store.getState());
});
```

---

### 📝 Guide

**With TypeScript**

```ts
// Create container
type State = { greeting: string };
const store = createContainer<State>({ greeting: "John" });

// Create action
type SetGreetingProps = { name: string };
const setGreeting = store.action<SetGreetingProps>((state, { name }) => ({
  greeting: name,
}));

// Call action
setGreeting({ name: "Doe" });
```

---

### 🌟 Features

- ✅ Actions
- ❌ Merge actions
- ✅ Subscription
- ✅ TypeScript Support
- ❌ Flow Support
- ❌ React binding

---

### 🔑 License

[MIT](https://oss.ninja/mit/rahmanfadhil)

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