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

refactor(store): use Object.is as default equality check #2245

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

arturovt
Copy link
Member

@arturovt arturovt commented Nov 3, 2024

In this commit, we default to using Object.is as the equality check function (this function is also used by other frameworks). Object.is supports checking for NaN values internally. We have also removed the reset function, as it was unused. If needed in the future, it can be re-added.

Copy link

nx-cloud bot commented Nov 3, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3daaa81. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

Copy link

pkg-pr-new bot commented Nov 3, 2024

Open in Stackblitz

@ngxs/devtools-plugin

yarn add https://pkg.pr.new/@ngxs/devtools-plugin@2245.tgz

@ngxs/form-plugin

yarn add https://pkg.pr.new/@ngxs/form-plugin@2245.tgz

@ngxs/hmr-plugin

yarn add https://pkg.pr.new/@ngxs/hmr-plugin@2245.tgz

@ngxs/router-plugin

yarn add https://pkg.pr.new/@ngxs/router-plugin@2245.tgz

@ngxs/storage-plugin

yarn add https://pkg.pr.new/@ngxs/storage-plugin@2245.tgz

@ngxs/store

yarn add https://pkg.pr.new/@ngxs/store@2245.tgz

@ngxs/websocket-plugin

yarn add https://pkg.pr.new/@ngxs/websocket-plugin@2245.tgz

commit: 3daaa81

Copy link

bundlemon bot commented Nov 3, 2024

BundleMon

Files updated (1)
Status Path Size Limits
fesm2022/ngxs-store-internals.mjs
11.3KB (-348B -2.92%) 13KB / +0.5%
Unchanged files (5)
Status Path Size Limits
fesm2022/ngxs-store.mjs
102.5KB 103KB / +0.5%
fesm2022/ngxs-store-internals-testing.mjs
6.83KB 7KB / +0.5%
fesm2022/ngxs-store-operators.mjs
6.22KB 7KB / +0.5%
fesm2022/ngxs-store-plugins.mjs
2.04KB 3KB / +0.5%
fesm2022/ngxs-store-experimental.mjs
1.4KB 2KB / +0.5%

Total files change -348B -0.26%

Groups updated (2)
Status Path Size Limits
@ngxs/store(fesm2022)[gzip]
./fesm2022/*.mjs
31.13KB (-127B -0.4%) +1%
@ngxs/store(esm2022)[gzip]
./esm2022/**/*.mjs
224.18KB (-448B -0.19%) +1%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Copy link

bundlemon bot commented Nov 3, 2024

BundleMon (NGXS Plugins)

Unchanged files (9)
Status Path Size Limits
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin.m
js
4.15KB +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin.mjs
3.2KB +0.5%
Plugins(fesm2022)[gzip]
websocket-plugin/fesm2022/ngxs-websocket-plug
in.mjs
2.64KB +0.5%
Plugins(fesm2022)[gzip]
hmr-plugin/fesm2022/ngxs-hmr-plugin.mjs
2.61KB +0.5%
Plugins(fesm2022)[gzip]
form-plugin/fesm2022/ngxs-form-plugin.mjs
2.59KB +0.5%
Plugins(fesm2022)[gzip]
devtools-plugin/fesm2022/ngxs-devtools-plugin
.mjs
2.23KB +0.5%
Plugins(fesm2022)[gzip]
logger-plugin/fesm2022/ngxs-logger-plugin.mjs
2.03KB +0.5%
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin-i
nternals.mjs
875B +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin-int
ernals.mjs
411B +0.5%

No change in files bundle size

Unchanged groups (1)
Status Path Size Limits
All Plugins(fesm2022)[gzip]
./-plugin/fesm2022/.mjs
20.71KB +0.5%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Copy link

bundlemon bot commented Nov 3, 2024

BundleMon (Integration Projects)

Files updated (3)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng16/dist-integration/main.(hash)
.js
67.76KB (-34B -0.05%) +1%
Main bundles(Gzip)
hello-world-ng17/dist-integration/main.(hash)
.js
68.64KB (-42B -0.06%) +1%
Main bundles(Gzip)
hello-world-ng18/dist-integration/browser/mai
n-(hash).js
71.81KB (-51B -0.07%) +1%

Total files change -127B -0.06%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Copy link
Member

@markwhitfeld markwhitfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find!!!

Comment on lines 62 to 66
(<any>memoized).reset = function () {
// The hidden (for now) ability to reset the memoization
lastArgs = null;
lastResult = null;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of this function is unrelated to this PR.
And besides, what is the motivation to remove it?

PS. The PR also requires an update to the changelog

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove it in another PR, but that part should not be included in the code unless it’s ever used. Extra work is bad, so unless there’s a valid argument for including that extra code, it shouldn’t be there.

In this commit, we default to using `Object.is` as the equality check function
(this function is also used by other frameworks). `Object.is` supports checking for `NaN`
values internally. We have also removed the reset function, as it was unused. If needed
in the future, it can be re-added.
Copy link

codeclimate bot commented Nov 8, 2024

Code Climate has analyzed commit 3daaa81 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 95.3% (-0.1% change).

View more on Code Climate.

@arturovt arturovt merged commit 583f543 into master Nov 8, 2024
15 checks passed
@arturovt arturovt deleted the refactor/object-is branch November 8, 2024 20:48
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.

2 participants