1.1.2 • Published 6 years ago

typesafereduxstate-js v1.1.2

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

Build Status

TypeSafeReduxState-JS

Functional, type-safe Redux state.

To use this State:

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:

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:

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:

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:

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.

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago