# @defx/s4

> Minimalist UI State Container inspired by Redux

Latest version **0.0.4** (published 2023-04-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @defx/s4
pnpm add @defx/s4
yarn add @defx/s4
bun add @defx/s4
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-04-05 |
| First published | 2023-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | defx |

## Links

- npm: https://www.npmjs.com/package/@defx/s4
- Repository: https://github.com/defx/s4
- Homepage: https://github.com/defx/s4#readme
- Issues: https://github.com/defx/s4/issues
- npm.io page: https://npm.io/package/@defx/s4

## Dependencies (1)

- [mocha-express](https://npm.io/package/mocha-express.md) ^0.1.2

## Recent versions

- 0.0.4 (latest) — 2023-04-05
- 0.0.3 — 2023-04-03
- 0.0.2 — 2023-03-31
- 0.0.1 — 2023-03-31

## README

<div align="center">

# @defx/s4

## A Simple redux-like UI state container

</div>
<br />

@defx/s4 is a ~350b JavaScript library consisting of...

```js
import { configure, dispatch, subscribe, getState } from "@defx/s4"
```

### Install via NPM

```sh
npm install @defx/s4
```

### Import via CDN

```js
import {
  configure,
  dispatch,
  subscribe,
  getState,
} from "https://www.unpkg.com/@defx/s4"
```

## API

### configure

```ts
function configure(
  /**
   * The reducer function will handle each action that is dispatched and return the new state
   */
  fn: Reducer,
  /**
   * (optional) An array of middleware functions that will be invoked immediately after an action is dispatched and before it is passed to the reducer.
   */
  middleware?: Middleware[]
): void
```

### dispatch

```ts
function dispatch(
  /**
   * The name of the action
   */
  type: string,
  /**
   * An object containing any values required to update state
   */
  payload: SerialisableObject
)
```

### subscribe

```ts
function subscribe(
  /**
   * The subscription callback will be invoked with the current state whenever the state has changed
   */
  fn: SubscriptionCallback
)
```

...

### getState

```ts
/**
 * Returns a copy of the current state
 */
function getState(): SerialisableObject
```

### ready

```ts
/**
 * A Promise that will resolve once the store is configured
 */
ready: Promise<void>
```

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