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

feat: Allow ctrl.set() value to be a function #3129

Merged
merged 1 commit into from
Jun 22, 2024
Merged

feat: Allow ctrl.set() value to be a function #3129

merged 1 commit into from
Jun 22, 2024

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Jun 22, 2024

Motivation

In case the value depends on previous value this eliminates race conditions.

Solution

Allow ctrl.set() value to be a function

This prevents race conditions.

const id = '2';
ctrl.set(Article, { id }, article => ({ id, votes: article.votes + 1 }));

Copy link

changeset-bot bot commented Jun 22, 2024

🦋 Changeset detected

Latest commit: aed65d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@data-client/core Patch
@data-client/react Patch
example-benchmark Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: aed65d9 Previous: c18fbf7 Ratio
normalizeLong 426 ops/sec (±1.95%) 417 ops/sec (±1.95%) 0.98
infer All 9534 ops/sec (±0.63%) 9209 ops/sec (±1.80%) 0.97
denormalizeLong 342 ops/sec (±1.06%) 299 ops/sec (±3.64%) 0.87
denormalizeLong donotcache 886 ops/sec (±0.33%) 847 ops/sec (±0.34%) 0.96
denormalizeShort donotcache 500x 1372 ops/sec (±0.20%) 1334 ops/sec (±0.24%) 0.97
denormalizeShort 500x 963 ops/sec (±0.72%) 954 ops/sec (±0.57%) 0.99
denormalizeShort 500x withCache 4995 ops/sec (±0.36%) 4700 ops/sec (±1.02%) 0.94
denormalizeLong with mixin Entity 290 ops/sec (±0.33%) 276 ops/sec (±0.89%) 0.95
denormalizeLong withCache 6131 ops/sec (±0.20%) 6938 ops/sec (±0.63%) 1.13
denormalizeLong All withCache 6413 ops/sec (±0.17%) 6490 ops/sec (±1.23%) 1.01
denormalizeLong Query-sorted withCache 6235 ops/sec (±0.60%) 6419 ops/sec (±0.42%) 1.03
denormalizeLongAndShort withEntityCacheOnly 1457 ops/sec (±0.49%) 1437 ops/sec (±0.75%) 0.99
getResponse 5961 ops/sec (±1.13%) 6205 ops/sec (±1.31%) 1.04
getResponse (null) 5949106 ops/sec (±0.95%) 5800428 ops/sec (±1.03%) 0.98
getResponse (clear cache) 288 ops/sec (±0.25%) 278 ops/sec (±0.91%) 0.97
getSmallResponse 2615 ops/sec (±0.21%) 2614 ops/sec (±0.47%) 1.00
getSmallInferredResponse 1980 ops/sec (±0.13%) 1952 ops/sec (±0.33%) 0.99
getResponse Query-sorted 5404 ops/sec (±0.64%) 4939 ops/sec (±2.20%) 0.91
getResponse Collection 6101 ops/sec (±0.56%) 6016 ops/sec (±0.67%) 0.99
get Collection 4997 ops/sec (±1.28%) 4774 ops/sec (±1.67%) 0.96
setLong 434 ops/sec (±2.04%) 403 ops/sec (±2.36%) 0.93
setLongWithMerge 177 ops/sec (±1.52%) 167 ops/sec (±1.93%) 0.94
setLongWithSimpleMerge 186 ops/sec (±1.23%) 173 ops/sec (±1.59%) 0.93
setSmallResponse 500x 847 ops/sec (±1.18%) 831 ops/sec (±1.54%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

codecov bot commented Jun 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.79%. Comparing base (c18fbf7) to head (aed65d9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3129   +/-   ##
=======================================
  Coverage   98.79%   98.79%           
=======================================
  Files         127      127           
  Lines        2238     2242    +4     
  Branches      453      455    +2     
=======================================
+ Hits         2211     2215    +4     
  Misses         16       16           
  Partials       11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ntucker ntucker merged commit 2503402 into master Jun 22, 2024
26 checks passed
@ntucker ntucker deleted the set-function branch June 22, 2024 12:19
@github-actions github-actions bot mentioned this pull request Jun 22, 2024
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.

1 participant