-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
State / Action sanitizer refactoring/bugfix + options fix #855
Conversation
…ools when doing export->import->export
…ls-extension when doing state replacement
} | ||
} | ||
|
||
private sanitizeAction(action: LiftedAction, actionIdx: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the sanitizer as an argument instead of checking its presence from the config inside the function.
: action; | ||
} | ||
|
||
private sanitizeStates(states: ComputedState[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the sanitizer as an argument instead of checking its presence from the config inside the function.
} | ||
|
||
private sanitizeState(state: any, stateIdx: number) { | ||
return this.config.stateSanitizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the sanitizer as an argument instead of checking its presence from the config inside the function.
} | ||
|
||
private getExtensionConfig() { | ||
const extensionOptions: ReduxDevtoolsExtensionConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the config as an argument instead of using it inside the function
These changes look reasonable to me. I left some comments on minor tweaks. I would also consider moving the sanitization functions to the |
Thanks for the feedback! I added a commit implementing your suggestions. |
Thanks! |
…grx#855) * Also refactors state / action sanitization * Improved consistency for config object provided to extension * Moved action/state sanitization functions into utils
The new state / action sanitization feature added by #544 and #795 has a bug:
This may now be an edge case, but, if the persist feature would get implemented (which under the hood is basically export/import), it may occur very often.
This is because the redux devtools extension does not know about any sanitizedActionsById object and will not update that. But the ngrx devtools reducer relied on this getting updated. This PR moves the state / action sanitization out of the reducer into the DevtoolsExtension service. Now, the sanitization is done directly before passing the state updates to the redux devtools extension. This makes the code more clear and fixes that bug.
During this I noticed that the options object which is handed to the devtools extension on startup is different to the options object which is sent on a full state replacement. Fixed that, too.
No worries on the big added/removed lines count in the store.spec.ts btw, I only removed the now obsolete tests for sanitizedActionsById, but for some reason git made that into a "replaced the whole file"-commit.