Skip to content

Commit a1e8bec

Browse files
markeriksonphryneastgoualalex111Lenz Weber
authored
v1.3.0 Integration (#374)
* Port ngrx/entity and add createAsyncThunk (#352) * Initial port of `@ngrx/entity` implementation * Remove deprecated addAll method * Port `@ngrx/entity` tests * Simplify immutable entity operations by wrapping with Immer * Don't overwrite state.ids if sorting order hasn't changed * Simplify state adapter logic using Immer - Removed all references to DidMutate enum - Removed unneeded logic that only checked if state was mutated * Add `isFSA` helper to createAction * Swap state operator order to `(state, arg)` and support FSAs - Swapped arguments to state operators so that they can be reused as mostly standard Redux reducers - Added a check to handle arg as either an FSA action or a value - Swapped argument order in all test cases - Added one test to provide reading payload from FSAs works * Add a test to verify adapter usage with createSlice * Document unexpected Immer behavior with nested produce calls * Quiet lint warnings in tests I have no idea why the NgRx code is mutating the Array prototype in the first place, but let's leave that there for now. * Export Entity types as part of the public API * Add createAsyncThunk * Export createAsyncThunk as part of the public API * Ignore VS Code folder * Mark new types as alpha * 1.3.0-alpha.0 * Remove `removeMany(predicate)` overload * Rework dispatched thunk action contents - Move args inside `meta` - Include contents directly as `payload` * Update public API types * typings experiment * Update createAsyncThunk tests to match API changes * Simplify entity ID type definitions * Add a basic request ID counter to createAsyncThunk * Add nanoid * Include requestId in payload creator args, and use nanoid * Hopefully fix type definitions for empty thunk action params - Made `ActionParams = void`, which allows not declaring any args in the payload creation function without TS complaining - Found out I can switch the args order back so it's `(args, other)` * Add overloads to make EntityAdapter methods createSlice-compatible The overloads that had `TypeOrPayloadAction<T>` were resulting in a payload of `undefined` for the associated action creator when passed directly as a case reducer to `createSlice`. Adding overloads that explicitly reference `PayloadAction<T>` allows the inference to work correctly so that action payloads are detected. * Add a test that combines slices, async thunks, and entities * Remove TS 3.3 and 3.4 from the Travis setup * Update public API * 1.3.0-alpha.1 * Rework createAsyncThunk error handling behavior - Removed `finished` action - Serialized `Error` objects to a plain object - Ensured errors in `fulfilled` dispatches won't get caught wrongly - Changed to re-throw errors in case the user wants to handle them * Update public API * 1.3.0-alpha.2 * createAsyncThunk return fulfilled/rejected action instead of re-… (#361) * createAsyncThunk return fulfilled/rejected action instead of re-trowing errors * add unwrapResult helper * add .abort() to the createAsyncThunk thunkAction (#362) * add .abort() to the createAsyncThunk thunkAction * per review comments * put `abort` on the promise returned by `dispatch(asyncThunk())` * remove reference to DOMException * simplify rejected action creator * fix error==undefined case, reduce diff * update api report * Add initial `getAsyncThunk` API docs and usage guide * Rename thunk types and fields and export SerializedError * Update public API * 1.3.0-alpha.3 * Initial fix for createAsyncThunk thunk types * Rework `createAsyncThunk` types to enable specifying getState type * Fix thunk test types * Update public API * 1.3.0-alpha.4 * manually import types to prevent a bundling issue * strongly type slice name (#354) * strongly type slice name * move new generic to the end and default it to string * use ThunkApiConfig for optional type arguments (#364) * 1.3.0-alpha.5 * Modify createStateOperator to detect and handle Immer drafts * Update link styling to match main Redux site * Update blockquote styling to match main Redux site * Update side category menu styling to match main Redux site * Consolidate Update generic type and remove unused overload * Update `combinedTest` based on `createStateOperator` fixes * Add API docs for `createEntityAdapter` * guess what time it is again - it's public API time! * 1.3.0-alpha.6 * Remove accidental yarn.lock * Try fixing Netlify deploys: 1 * Update DS to fix sidebar bug * Try forcing node version * createAsyncThunk improvements (#367) * prevent dispatching of further actions if asyncThunk has been cancelled, even if the payloadCreator didn't react to the `abort` request * * add race between payloadCreator and abortedPromise * simplify createAsyncThunk * remove complicated logic where an AbortError thrown from the `payloadCreator` could influence the return value * api report * doc examples for cancellation * Remove extraneous period from abort message * Reorder cancellation content and improve wording * Fix code padding color busted from DS alpha.41 * 1.3.0-alpha.7 * Update Docusaurus and add lockfile to 43 version (#369) * Update Docusaurus and add lockfile to 43 version * Fix lockfile * Update netlify.toml to remove Yarn command * Try forcing node version Co-authored-by: Mark Erikson <mark@isquaredsoftware.com> * Try adding the compressed-size-action (#372) * Fix potential entity bugs identified by code review - Comparer should always return a number for sorting - Fixed missed state arg in add/remove test - Added test to confirm expected ID change behavior - Fixed bug in updateMany where multiple renames of one ID led to corrupted values in entities table afterwards * do that public API thing * Document caveats with update operations Co-authored-by: Lenz Weber <mail@lenzw.de> Co-authored-by: Thibault Gouala <thibault.gouala@gmail.com> Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com> * 1.3.0-alpha.8 * remove `any` where applicable (#377) * remove `any` where applicable * re-add `| undefined`, remove review comments * Fork redux-devtools-extension (#384) * Only check format for Markdown files in /docs * Add TS port of redux-devtools extension and use it * Remove redux-devtools-extension dependency * Remove stray console logs from tests * Feature/immutable invariant (#381) * strongly type slice name (#354) * strongly type slice name * move new generic to the end and default it to string * Remove accidental yarn.lock * Update DS to fix sidebar bug * Update Docusaurus and add lockfile to 43 version (#369) * Update Docusaurus and add lockfile to 43 version * Fix lockfile * Update netlify.toml to remove Yarn command * Try forcing node version Co-authored-by: Mark Erikson <mark@isquaredsoftware.com> * Try adding the compressed-size-action (#372) * Port redux-immutable-invariant and update docs * Update lock * Keep immutable middleware interface types during build * Readd lock file * Add mention of being a fork of redux-immutable-state-invariant * Markdown formatting Co-authored-by: Thibault Gouala <thibault.gouala@gmail.com> Co-authored-by: Mark Erikson <mark@isquaredsoftware.com> Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com> * Immutable middleware cleanup (#385) * Inline tiny-invariant and json-stringify-safe * Remove unused deps * Tweak immutable middleware docs typos * TS dep updates (#386) * Update createEntityAdapter type reference * Update TypeScript and Prettier to latest * Prettier reformatting * 1.3.0-alpha.9 * update TS docs, add new 1.3.0 APIs (#388) * Docs: add info on how to type Meta in `createSlice` * Docs: better example for signal.addEventListener * docs: TS usage for `createAsyncThunk` * docs: TS docs for `createEntityAdapter` * Edit new TS usage docs Co-authored-by: Mark Erikson <mark@isquaredsoftware.com> * Clarify createAsyncThunk type handling * Use Immer 6 alpha (#396) * Use fork of nanoid * Remove nanoid * Update to Immer 6 alpha * Enable Immer 6's ES5 support * Add TS 3.8 coverage * 1.3.0-alpha.10 * Formatting * RFC createAsyncThunk: reject with typed value (#393) * createAsyncThunk: add rejectWithValue function * Update docs on createAsyncThunk usage, add tests for rejectWithValue, fix rejected error return * implement AbortController stub for node, react native & IE Co-authored-by: Matt Sutkowski <msutkowski@gmail.com> * remove createSerializableStateInvariantMiddleware and createImmutableStateInvariantMiddleware functionality from production builds (#406) * bump immer to v6 (#407) * Immer 6 final (#409) * Update to Immer 6.0.1 * Fix AbortController test * Ignore serializability of `meta.args` by default (#410) * 1.3.0-beta.0 * display a warning if `immutableStateInvariantMiddleware` or `ser… (#427) * display a warning if `immutableStateInvariantMiddleware` or `serializableStateInvariantMiddleware` take too long * Update src/utils.ts Co-authored-by: Mark Erikson <mark@isquaredsoftware.com> * simplify signatures of `ActionCreatorWithOptionalPayload` and `A… (#428) * prevent any-casting of S generic on entityAdapter reducer-like f… (#436) * prevent any-casting of S generic on entityAdapter reducer-like functions * remove `map` from entityAdapter * remove references to `map` from the docs * update API report * remove export * Fix bug in docs for createAsyncThunk example (#417) fetchUserById payloadCreator should fetch when in pending (not idle) state * Feature/entity selectors (#440) * Add a `selectById` selector * Export Reselect types * Update API * 1.3.0-beta.1 * Update list of APIs and README Co-authored-by: Lenz Weber <mail@lenzw.de> Co-authored-by: Thibault Gouala <thibault.gouala@gmail.com> Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com> Co-authored-by: Lenz Weber <lenz.weber@mayflower.de> Co-authored-by: Matt Sutkowski <msutkowski@gmail.com> Co-authored-by: David Walsh <dlwalsh@gmail.com>
1 parent de26824 commit a1e8bec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5665
-228
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_modules
44
dist
55
lib
66
es
7+
yarn.lock
78

89

910
.idea/

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ language: node_js
22
node_js: node
33
env:
44
- TYPESCRIPT_VERSION=rc
5+
- TYPESCRIPT_VERSION=3.8
56
- TYPESCRIPT_VERSION=3.7
67
- TYPESCRIPT_VERSION=3.6
78
- TYPESCRIPT_VERSION=3.5
8-
- TYPESCRIPT_VERSION=3.4
9-
- TYPESCRIPT_VERSION=3.3
109
install:
1110
- npm ci --ignore-scripts
1211
- npm install typescript@$TYPESCRIPT_VERSION

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[![build status](https://img.shields.io/travis/reduxjs/redux-toolkit/master.svg?style=flat-square)](https://travis-ci.org/reduxjs/redux-toolkit)
44
[![npm version](https://img.shields.io/npm/v/@reduxjs/toolkit.svg?style=flat-square)](https://www.npmjs.com/package/@reduxjs/toolkit)
55
[![npm downloads](https://img.shields.io/npm/dm/@reduxjs/toolkit.svg?style=flat-square&label=RTK+downloads)](https://www.npmjs.com/package/@reduxjs/toolkit)
6-
[![npm downloads](https://img.shields.io/npm/dm/redux-starter-kit.svg?style=flat-square&label=RSK+downloads)](https://www.npmjs.com/package/redux-starter-kit)
76

87
**The official, opinionated, batteries-included toolset for efficient Redux development**
98

@@ -44,16 +43,18 @@ The **Redux Toolkit** package is intended to be the standard way to write Redux
4443

4544
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.
4645

47-
This package is _not_ intended to solve every possible use case for 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.
46+
Because of that, this package is deliberately limited in scope. It does _not_ address concepts like "reusable encapsulated Redux modules", data caching, folder or file structures, managing entity relationships in the store, and so on.
4847

4948
## What's Included
5049

51-
Redux Toolkit includes:
50+
Redux Toolkit includes these APIs:
5251

53-
- 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.
54-
- 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`.
55-
- 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.
56-
- A `createSlice()` function that accepts a set of reducer functions, a slice name, and an initial state value, and automatically generates a slice reducer with corresponding action creators and action types.
52+
- `configureStore()`: wraps `createStore` to provide simplified configuration options and good defaults. 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.
53+
- `createReducer()`: 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`.
54+
- `createAction()`: generates 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.
55+
- `createSlice()`: accepts an object of reducer functions, a slice name, and an initial state value, and automatically generates a slice reducer with corresponding action creators and action types.
56+
- `createAsyncThunk`: accepts an action type string and a function that returns a promise, and generates a thunk that dispatches `pending/resolved/rejected` action types based on that promise
57+
- `createEntityAdapter`: generates a set of reusable reducers and selectors to manage normalized data in the store
5758
- The `createSelector` utility from the [Reselect](https://github.com/reduxjs/reselect) library, re-exported for ease of use.
5859

5960
## Documentation

0 commit comments

Comments
 (0)