# typesafereduxstate-js

> Functional, type-safe Redux state

Latest version **1.1.2** (published 2018-01-22) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install typesafereduxstate-js
pnpm add typesafereduxstate-js
yarn add typesafereduxstate-js
bun add typesafereduxstate-js
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-01-22 |
| First published | 2017-12-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hai Pham |
| Maintainers | haipham |

## Links

- npm: https://www.npmjs.com/package/typesafereduxstate-js
- Repository: https://github.com/protoman92/TypeSafeReduxState-JS
- Homepage: https://github.com/protoman92/TypeSafeReduxState-JS#readme
- Issues: https://github.com/protoman92/TypeSafeReduxState-JS/issues
- npm.io page: https://npm.io/package/typesafereduxstate-js

## Dependencies (1)

- [javascriptutilities](https://npm.io/package/javascriptutilities.md) ^1.2.6

## Recent versions

- 1.1.2 (latest) — 2018-01-22
- 1.1.1 — 2018-01-11
- 1.1.0 — 2018-01-10
- 1.0.9 — 2018-01-10
- 1.0.8 — 2018-01-09
- 1.0.7 — 2018-01-09
- 1.0.6 — 2018-01-06
- 1.0.5 — 2018-01-04
- 1.0.4 — 2017-12-28
- 1.0.3 — 2017-12-28
- 1.0.2 — 2017-12-28
- 1.0.1 — 2017-12-28
- 1.0.0 — 2017-12-28

## README

[![Build Status](https://travis-ci.org/protoman92/TypeSafeReduxState-JS.svg?branch=master)](https://travis-ci.org/protoman92/TypeSafeReduxState-JS)

# TypeSafeReduxState-JS
Functional, type-safe Redux state.

To use this State:

```typescript
import { State } from 'typesafereduxstate-js';
```

This State object contains the a key-value object of the current state values, as well as a key-value object of nested substates. To access the value at any node, use:

```typescript
state.valueAtNode(string);
```

The parameter of this function should be a String whose components are joined with the specified substateSeparator (which is by default '.'). For example:

```typescript
state.valueAtNode('a.b.c.d.e');
```

The above call will access the value at key **'e'** of substate **'a.b.c.d'**.

In order to update the value at some node, call:

```typescript
state.updatingValue(string, Nullable<any>);
```

The State object will update the value at that node, and if necessary create new substates along the way.

This State is useful for Redux reducers because you will not need to check for existence of property keys before updating value at a node. A reducer can be as such:

```typescript
function reduce(state: State.Self<any>, action: Action): State.Self<any> {
  return state
    .updatingValue('auth.login.username', action.username)
    .updatingValue('auth.login.password', action.password)
    .updatingValue('auth.login.email', action.email);
}
```

As a result, we have a robust, functional set of reducers.

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