1.1.0 • Published 7 years ago

redux-loading-reducer v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

Redux-loading-reducer

A simple function (reducer) that changes custom state flag. The main purpose is to change a flag, such as isLoading, by given arrays of loading action names and not-loading action names. Reducer is curried, so some args can be passed before.

Usage

import makeLoadingReducer from 'redux-loading-reducer';

const loadingActions = [
  'FIRST_LOADING_ACTION'
  'SECOND_LOADING_ACTION'
];

const notLoadingActions = [
  'ONLY_NOT_LOADING_ACTION'
];

const reducerWrapper = makeLoadingReducer('myCustomStateKeyName', loadingActions, notLoadingActions);

const myReducer = reducerWrapper((state, action) => {
  // handling my own actions
};

Arguments

NameTypePurpose
stateBranchKeyNamestringRequired. Key name that can be seen in state branch
loadingActionNamesarrayRequired. Array of loading-like action names, that Loading Reducer will look for changing flag to true
notLoadingActionNamesarrayRequired. Array of not loading-like action names, that Loading Reducer will look for changing flag to false
reducerfunctionRequired. Reducer to be wrapped

Other

Otherwise, this function be used for change any custom flag, like isLogged, etc. Let treat then this with your own way.

1.1.0

7 years ago

1.0.9

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago