@codewell/state-actions

1.0.1 • Public • Published

@codewell/state-actions

Installation

npm install @codewell/state-actions

Basic usage

Set state property

Setting a state property overrides the current value of a state property.

import { setStateProperty } from '@codewell/state-actions';

const state = { foo: 'foo' };

const actoin = { payload: 'bar' };

setStateProperty(state, action, 'foo');
// => {foo: 'bar'}

Update state property

Updates some (or all) fields of a state property.

import { updateStateProperty } from '@codewell/state-actions';

const state = { foo: {
  one: 1,
  two: 0,
} };

const actoin = { payload: {two: 2, three: 3} };

updateStateProperty(state, action, 'foo');
// => {foo: {one: 1, two: 2, three: 3}}

Remove state property

Removes a property from the state.

import { removeStateProperty } from '@codewell/state-actions';

const state = { foo: 'foo' };

removeStateProperty(state, 'foo');
// => {}

Readme

Keywords

none

Package Sidebar

Install

npm i @codewell/state-actions

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

4.79 kB

Total Files

8

Last publish

Collaborators

  • fippli