Skip to content

A redux reducer-generator which builds a redux-reducer which matches against wildcards.

License

Notifications You must be signed in to change notification settings

Dash-OS/reducer-generator-wildcard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reducer-generator-wildcard

A reducer-generator which builds a redux-reducer which matches against wildcard types.

Under the hood this utilizes our package wildcard-utils which allows us to match strings against objects of wildcards.

Installation

yarn add reducer-generator-wildcard

or

npm install --save reducer-generator-wildcard

Simple Example

import createWildcardReducer from 'reducer-generator-wildcard'

// match any types that start with SYSTEM
const system = createWildcardReducer(
  { /* initial state */ }, 
  {
    // match any types that begin with SYSTEM
    'SYSTEM*': (state, { type, ...action }) => ({
      ...state,
      isOnline: action.isOnline !== undefined
        ? action.isOnline
        : state.isOnline,
    }),
  },
  /* You may pass extra args that will be passed to the reducer(s) */
)

About

A redux reducer-generator which builds a redux-reducer which matches against wildcards.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published