Skip to content

jerryslaw/redux-loading-reducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Name Type Purpose
stateBranchKeyName string Required. Key name that can be seen in state branch
loadingActionNames array Required. Array of loading-like action names, that Loading Reducer will look for changing flag to true
notLoadingActionNames array Required. Array of not loading-like action names, that Loading Reducer will look for changing flag to false
reducer function Required. 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published