Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-starter-kit

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-starter-kit - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

8

dist/redux-starter-kit.cjs.js

@@ -7,5 +7,5 @@ 'use strict';

var redux = require('redux');
var createNextState = _interopDefault(require('immer'));
var selectorator = _interopDefault(require('selectorator'));
var redux = require('redux');
var reduxDevtoolsExtension = require('redux-devtools-extension');

@@ -282,2 +282,3 @@ var thunk = _interopDefault(require('redux-thunk'));

actionCreator.type = type;
return actionCreator;

@@ -371,2 +372,3 @@ }

var reducers = options.reducers || {};
var extraReducers = options.extraReducers || {};
var actionKeys = Object.keys(reducers);

@@ -376,3 +378,3 @@ var reducerMap = actionKeys.reduce(function (map, actionKey) {

return map;
}, {});
}, extraReducers);
var reducer = createReducer(initialState, reducerMap);

@@ -406,2 +408,4 @@ var actionMap = actionKeys.reduce(function (map, action) {

exports.combineReducers = redux.combineReducers;
exports.compose = redux.compose;
exports.createNextState = createNextState;

@@ -408,0 +412,0 @@ exports.createSelector = selectorator;

@@ -0,5 +1,6 @@

import { combineReducers, applyMiddleware, createStore, compose } from 'redux';
export { combineReducers, compose } from 'redux';
import createNextState from 'immer';
export { default as createNextState } from 'immer';
export { default as createSelector } from 'selectorator';
import { combineReducers, applyMiddleware, createStore, compose } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

@@ -276,2 +277,3 @@ import thunk from 'redux-thunk';

actionCreator.type = type;
return actionCreator;

@@ -365,2 +367,3 @@ }

var reducers = options.reducers || {};
var extraReducers = options.extraReducers || {};
var actionKeys = Object.keys(reducers);

@@ -370,3 +373,3 @@ var reducerMap = actionKeys.reduce(function (map, actionKey) {

return map;
}, {});
}, extraReducers);
var reducer = createReducer(initialState, reducerMap);

@@ -373,0 +376,0 @@ var actionMap = actionKeys.reduce(function (map, action) {

@@ -9,3 +9,5 @@ export { default as createNextState } from 'immer'

Store,
StoreEnhancer
StoreEnhancer,
combineReducers,
compose
} from 'redux'

@@ -12,0 +14,0 @@ export { default as createSelector } from 'selectorator'

{
"name": "redux-starter-kit",
"version": "0.4.0",
"version": "0.4.1",
"description": "A simple set of tools to make using Redux easier",

@@ -5,0 +5,0 @@ "repository": "https://github.com/markerikson/redux-starter-kit",

@@ -7,8 +7,4 @@ # Redux Starter Kit

**A simple set of tools to make using Redux easier**
[![npm downloads](https://img.shields.io/npm/dm/redux-starter-kit.svg?style=flat-square)](https://www.npmjs.com/package/redux-starter-kit)
`npm install redux-starter-kit`
(Special thanks to Github user @shotak for dona
**A simple set of tools to make using Redux easier**

@@ -22,3 +18,3 @@

The `redux-starter-kit` package is intended to help address three common complaints about Redux:
The `redux-starter-kit` package is intended to help address three common concerns about Redux:

@@ -29,5 +25,5 @@ - "Configuring a Redux store is too complicated"

We can't solve every use case, but in the spirit of le complaint about Redux, and is deliberately limited in scope. It and _not_ address concepts like "reusable encapsulated Redux modules", data fetching, folder or file s, we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://dev-blog.apollodata.com/zero-config-graphql-state-management-27b1f1b3c2c3), we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
This package is _not_ intended to solve every possible complaint about Redux, and is deliberately limited in scope. It does _not_ address concepts like "reusable encapsulated Redux modules", data fetching, folder or file structures, managing entity relationships in the store, and so on.
This package is _not_ intended to solve every possible concern about Redux, and is deliberately limited in scope. It does _not_ address concepts like "reusable encapsulated Redux modules", data fetching, folder or file structures, managing entity relationships in the store, and so on.

@@ -39,12 +35,11 @@ ### What's Included

- A `configureStore()` function with simplified configuration options. It can automatically combine your slice reducers, adds whatever Redux middleware you supply, includes `redux-thunk` by default, and enables use of the Redux DevTools Extension.
- A `createReducer()` utility that lets you supply a lookup table of action types to case reducer functions, rather than writing switch statements. In addition, it automatically uses the e selector functions.
- An improved version of the wid to let you write simpler immutable updates with normal mutative code, like `state.todos[3].completed = true`.
- A `createReducer()` utility that lets you supply a lookup table of action types to case reducer functions, rather than writing switch statements. In addition, it automatically uses the [`immer` library](https://github.com/mweststrate/immer) to let you write simpler immutable updates with normal mutative code, like `state.todos[3].completed = true`.
- A `createAction()` utility that returns an action creator function for the given action type string. The function itself has `toString()` defined, so that it can be used in place of the type constant.
- A `createSlice()` function that accepts a set of reducer functions, a slice name, and an initial state value, and automatically generates corresponding action creators, types, and simple selector functions.
- An improved version of the widely used `createSelector` utility for creating memoized selector functions, which can accept string keypaths as "input selectors" (re-exported from the n for more updates!).
- An improved version of the widely used `createSelector` utility for creating memoized selector functions, which can accept string keypaths as "input selectors" (re-exported from the [`selectorator` library](https://github.com/planttheidea/selectorator)).
## Documentation
The `redux-starter-kit` docs are now published at **tent - check back soon for more **.
The `redux-starter-kit` docs are now published at **https://redux-starter-kit.js.org**.
We're currently expanding and rewriting our docs content - check back soon for more updates!

@@ -21,2 +21,3 @@ import { Action } from 'redux'

(payload: P): PayloadAction<P, T>
type: T
}

@@ -35,3 +36,3 @@

type: T
): PayloadActionCreator<P> {
): PayloadActionCreator<P, T> {
function actionCreator(): Action<T>

@@ -43,4 +44,6 @@ function actionCreator(payload: P): PayloadAction<P, T>

actionCreator.toString = () => `${type}`
actionCreator.toString = (): T => `${type}` as T
actionCreator.type = type
return actionCreator

@@ -47,0 +50,0 @@ }

import { createSlice } from './createSlice'
import { createAction } from './createAction'

@@ -108,2 +109,23 @@ describe('createSlice', () => {

})
describe('when passing extra reducers', () => {
const addMore = createAction('ADD_MORE')
const { reducer } = createSlice({
reducers: {
increment: state => state + 1,
multiply: (state, action) => state * action.payload
},
extraReducers: {
[addMore.type]: (state, action) => state + action.payload.amount
},
initialState: 0
})
it('should call extra reducers when their actions are dispatched', () => {
const result = reducer(10, addMore({ amount: 5 }))
expect(result).toBe(15)
})
})
})

@@ -42,3 +42,4 @@ import { Action, AnyAction, ActionCreator, Reducer } from 'redux'

A extends Action = AnyAction,
CR extends CaseReducersMapObject<S, A> = CaseReducersMapObject<S, A>
CR extends CaseReducersMapObject<S, A> = CaseReducersMapObject<S, A>,
CR2 extends CaseReducersMapObject<S, A> = CaseReducersMapObject<S, A>
> {

@@ -62,2 +63,9 @@ /**

reducers: CR
/**
* A mapping from action types to action-type-specific *case reducer*
* functions. These reducers should have existing action types used
* as the keys, and action creators will _not_ be generated.
*/
extraReducers?: CR2
}

@@ -86,11 +94,9 @@

const reducers = options.reducers || {}
const extraReducers = options.extraReducers || {}
const actionKeys = Object.keys(reducers)
const reducerMap = actionKeys.reduce(
(map, actionKey) => {
map[getType(slice, actionKey)] = reducers[actionKey]
return map
},
{} as CR
)
const reducerMap = actionKeys.reduce((map, actionKey) => {
map[getType(slice, actionKey)] = reducers[actionKey]
return map
}, extraReducers)

@@ -97,0 +103,0 @@ const reducer = createReducer(initialState, reducerMap)

@@ -0,1 +1,2 @@

export { combineReducers, compose } from 'redux'
export { default as createNextState } from 'immer'

@@ -2,0 +3,0 @@ export { default as createSelector } from 'selectorator'

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc