redux-sputnik

Utils for redux

Usage no npm install needed!

<script type="module">
  import reduxSputnik from 'https://cdn.skypack.dev/redux-sputnik';
</script>

README

redux-sputnik

Utils for redux

Installation

npm install redux-sputnik

newAction

Creates an action

import { newAction } from 'redux-sputnik';

export const CommonActions = {
    myAction: (param: string) => newAction(CommonActionTypes.MY_ACTION, param),
}

newActionType

Creates action type identifier

import { newActionType } from 'redux-sputnik';

const prefix = 'common';

export const CommonTypes = {
    MY_ACTION: newActionType(prefix, 'MY_ACTION')
}

newReducer

Creates reducer

import { newReducersetState } from 'redux-sputnik';

const COMMON_INITIAL_STATE = {};

export const commonReducer = newReducer(AUTH_INITIAL_STATE, {
    [CommonTypes.MY_ACTION]: (state, params: string) => {
        return setState(state, _ => _.value, params};
    }
});

setState

Changes redux state

import { newReducer, setState } from 'redux-sputnik';

const COMMON_INITIAL_STATE = {};

export const commonReducer = newReducer(AUTH_INITIAL_STATE, {
    [CommonTypes.MY_ACTION]: (state, params: string) => {
        return setState(state, _ => _.value, params};
    }
});