Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.2k
RFC: configurableproduce implementation#3074
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
phryneas wants to merge28 commits intomasterChoose a base branch frompr/configure-produce-implementation
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes from1 commit
Commits
Show all changes
28 commits Select commitHold shift + click to select a range
49f808a allow `produce` to be swapped out in createReducer/createSlice
phryneasf0228f9 Make more Immer utils configurable
markeriksonfb9d324 add buildable createDraftSafeSelector
293a9b9 make configurable createEntityAdapter
83a8931 unused type
411568a declare immutable helper types once
d9e1341 build createDraftSafeSelector outside of createSelectorsFactory
e5f48f1 allow replacing RTKQ's usage of immer
4f6c897 use immutablehelpers for RTKQ's createSlice
28a87c9 named export instead of default
180d198 use specific freeze function instead of abusing createNextState
5bd963c export buildCreateEntityAdapter
bc924e7 Merge branch 'v2.0-integration' into more-produce
9f9dfff export ImmutableHelpers
a36f092 Merge branch 'v2.0-integration' into pr/configure-produce-implementation
27bcf3b Merge branch 'pr/configure-produce-implementation' into more-produce
19d5b8d create a defineImmutableHelpers identity function, and use for immer
9614298 don't use @internal import
7eb1fa0 import ImmutableHelpers type from RTK
115b856 fix entity adapter options not being optional
bfa1419 hope the PR gets happier
9d8f344 be extra assertive about nicking reselect's types
df861fd Merge pull request #3327 from EskiMojo14/more-produce
markerikson080974d Merge branch 'v2.0-integration' into pr/configure-produce-implementation
30b1b49 Merge branch 'v2.0-integration' into pr/configure-produce-implementation
EskiMojo147276087 Merge branch 'v2.0-integration' into pr/configure-produce-implementation
b43f501 rtkImports
0888fde add missing createEntityAdapter overload
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
add buildable createDraftSafeSelector
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
29 changes: 22 additions & 7 deletionspackages/toolkit/src/createDraftSafeSelector.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,33 @@ | ||
| import { current, isDraft } from 'immer' | ||
| import { createSelector } from 'reselect' | ||
| export interface BuildCreateDraftSafeSelectorConfiguration { | ||
| isDraft(value: any): boolean | ||
| current<T>(value: T): T | ||
| } | ||
| /** | ||
| * "Draft-Safe" version of `reselect`'s `createSelector`: | ||
| * If an `immer`-drafted object is passed into the resulting selector's first argument, | ||
| * the selector will act on the current draft value, instead of returning a cached value | ||
| * that might be possibly outdated if the draft has been modified since. | ||
| * @public | ||
| */ | ||
| export type CreateDraftSafeSelector = typeof createSelector | ||
| export function buildCreateDraftSafeSelector({ | ||
| isDraft, | ||
| current, | ||
| }: BuildCreateDraftSafeSelectorConfiguration): CreateDraftSafeSelector { | ||
| return function createDraftSafeSelector(...args: unknown[]) { | ||
| const selector = (createSelector as any)(...args) | ||
| const wrappedSelector = (value: unknown, ...rest: unknown[]) => | ||
| selector(isDraft(value) ? current(value) : value, ...rest) | ||
| return wrappedSelector as any | ||
| } | ||
| } | ||
| export const createDraftSafeSelector = buildCreateDraftSafeSelector({ | ||
| isDraft, | ||
| current, | ||
| }) |
6 changes: 5 additions & 1 deletionpackages/toolkit/src/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.