Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.3.0 Integration #374

Merged
merged 29 commits into from Mar 24, 2020
Merged

v1.3.0 Integration #374

merged 29 commits into from Mar 24, 2020

Conversation

markerikson
Copy link
Collaborator

WIP draft PR to collect all our v1.3.0 changes together, giving us docs preview, bundle size checks, etc.

* 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>
@netlify
Copy link

netlify bot commented Feb 19, 2020

Deploy preview for redux-starter-kit-docs ready!

Built with commit 5fea69c

https://deploy-preview-374--redux-starter-kit-docs.netlify.com

@github-actions
Copy link

github-actions bot commented Feb 19, 2020

Size Change: +13.3 kB (24%) 🚨

Total Size: 55.1 kB

Filename Size Change
dist/redux-toolkit.cjs.development.js 10.3 kB +6.13 kB (59%) 🆘
dist/redux-toolkit.cjs.production.min.js 3.67 kB +1.57 kB (42%) 🚨
dist/redux-toolkit.esm.js 10.3 kB +6.25 kB (60%) 🆘
dist/redux-toolkit.umd.js 21.5 kB -1.25 kB (5%)
dist/redux-toolkit.umd.min.js 9.2 kB +554 B (6%) 🔍
ℹ️ View Unchanged
Filename Size Change
dist/index.js 149 B 0 B

compressed-size-action

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 19, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d1e6c8c:

Sandbox Source
amazing-worker-i70hc Configuration
frosty-sun-yxyds Configuration
wispy-pond-m05kd Configuration

@markerikson markerikson mentioned this pull request Feb 19, 2020
18 tasks
Lenz Weber and others added 8 commits February 21, 2020 13:04
* remove `any` where applicable

* re-add `| undefined`, remove review comments
* 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
* 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>
* Inline tiny-invariant and json-stringify-safe

* Remove unused deps

* Tweak immutable middleware docs typos
* Update createEntityAdapter type reference

* Update TypeScript and Prettier to latest

* Prettier reformatting
* 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>
* Use fork of nanoid

* Remove nanoid

* Update to Immer 6 alpha

* Enable Immer 6's ES5 support

* Add TS 3.8 coverage
# Conflicts:
#	docs/usage/usage-guide.md
#	website/src/css/custom.css
@markerikson
Copy link
Collaborator Author

@phryneas I just saw someone in Discord report that they were getting non-serializable values in an action dispatched by createAsyncThunk, in a field like meta.args.someTimestamp. Looks like they're passing a Date instance to the payload creator.

This is an interesting issue, because strictly speaking passing non-serializable values to the payload creator should be entirely fine. It's only a problem because we're attaching those to the dispatched action.

Any thoughts on what the right approach is for dealing with that? Some possibilities:

  • Just document it and say "either don't pass non-serializable args to the payload creator, or explicitly ignore that action type in the serializability check"
  • Edit the serializability middleware to ignore action.meta.args by default

@phryneas
Copy link
Member

phryneas commented Mar 2, 2020

@phryneas I just saw someone in Discord report that they were getting non-serializable values in an action dispatched by createAsyncThunk, in a field like meta.args.someTimestamp. Looks like they're passing a Date instance to the payload creator.

This is an interesting issue, because strictly speaking passing non-serializable values to the payload creator should be entirely fine. It's only a problem because we're attaching those to the dispatched action.

Any thoughts on what the right approach is for dealing with that? Some possibilities:

* Just document it and say "either don't pass non-serializable args to the payload creator, or explicitly ignore that action type in the serializability check"

* Edit the serializability middleware to ignore `action.meta.args` by default

One step further: have the serializability middleware ignore all action.meta by default? Would be a nice escape hatch to pass non-serializable data to middlewares etc without having to stop action propagation.

@markerikson
Copy link
Collaborator Author

Mmm... the serializable middleware should generally be after all others anyway unless you've reordered things, which is why it's okay to dispatch thunk functions in the first place.

But yeah, let's at least specifically exempt meta.args, since that's not even something the user is explicitly adding to the action themselves.

markerikson and others added 5 commits March 4, 2020 14:10
* 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>
…StateInvariantMiddleware functionality from production builds (#406)
* Update to Immer 6.0.1

* Fix AbortController test
markerikson and others added 3 commits March 5, 2020 09:42
* display a warning if `immutableStateInvariantMiddleware` or `serializableStateInvariantMiddleware` take too long

* Update src/utils.ts

Co-authored-by: Mark Erikson <mark@isquaredsoftware.com>
phryneas and others added 5 commits March 21, 2020 14:43
* 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
fetchUserById payloadCreator should fetch when in pending (not idle) state
* Add a `selectById` selector

* Export Reselect types

* Update API
@markerikson markerikson marked this pull request as ready for review March 24, 2020 02:04
@markerikson
Copy link
Collaborator Author

3, 2, 1, let's jam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants