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

enhance: Manager.getMiddleware() -> Manager.middleware #3164

Merged
merged 1 commit into from
Jul 25, 2024
Merged

enhance: Manager.getMiddleware() -> Manager.middleware #3164

merged 1 commit into from
Jul 25, 2024

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Jul 25, 2024

Motivation

Simplification

Solution

We previously used getMiddleware() so we wouldn't have to worry about object binding (we could assign middleware variable instead of calling manager.middleware()). However, applyManagers gives us full control of how it is is called, so this is no longer necessary.

Before

class LoggingManager implements Manager {
  getMiddleware = (): Middleware => controller => next => async action => {
    console.log('before', action, controller.getState());
    await next(action);
    console.log('after', action, controller.getState());
  };

  cleanup() {}
}

After

class LoggingManager implements Manager {
  middleware: Middleware => controller => next => async action => {
    console.log('before', action, controller.getState());
    await next(action);
    console.log('after', action, controller.getState());
  };

  cleanup() {}
}

Copy link

changeset-bot bot commented Jul 25, 2024

🦋 Changeset detected

Latest commit: 5bc8b3a

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/react Patch
@data-client/core 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: 5bc8b3a Previous: 262587c Ratio
normalizeLong 503 ops/sec (±0.33%) 525 ops/sec (±0.42%) 1.04
infer All 9748 ops/sec (±0.72%) 9353 ops/sec (±2.56%) 0.96
denormalizeLong 335 ops/sec (±1.53%) 335 ops/sec (±2.38%) 1
denormalizeLong donotcache 885 ops/sec (±0.22%) 880 ops/sec (±0.22%) 0.99
denormalizeShort donotcache 500x 1352 ops/sec (±0.47%) 1372 ops/sec (±0.13%) 1.01
denormalizeShort 500x 984 ops/sec (±0.33%) 957 ops/sec (±0.31%) 0.97
denormalizeShort 500x withCache 5082 ops/sec (±0.20%) 4990 ops/sec (±0.19%) 0.98
denormalizeLong with mixin Entity 302 ops/sec (±0.22%) 299 ops/sec (±0.68%) 0.99
denormalizeLong withCache 6752 ops/sec (±0.29%) 6119 ops/sec (±0.12%) 0.91
denormalizeLong All withCache 6379 ops/sec (±0.18%) 6227 ops/sec (±0.20%) 0.98
denormalizeLong Query-sorted withCache 6248 ops/sec (±0.55%) 6058 ops/sec (±0.65%) 0.97
denormalizeLongAndShort withEntityCacheOnly 1495 ops/sec (±0.40%) 1517 ops/sec (±0.70%) 1.01
getResponse 5980 ops/sec (±1.14%) 5999 ops/sec (±1.05%) 1.00
getResponse (null) 5272753 ops/sec (±0.92%) 5294998 ops/sec (±0.94%) 1.00
getResponse (clear cache) 297 ops/sec (±0.28%) 294 ops/sec (±0.57%) 0.99
getSmallResponse 2645 ops/sec (±0.20%) 2622 ops/sec (±0.06%) 0.99
getSmallInferredResponse 2036 ops/sec (±0.19%) 2038 ops/sec (±0.13%) 1.00
getResponse Query-sorted 6650 ops/sec (±0.54%) 5561 ops/sec (±0.26%) 0.84
getResponse Collection 6628 ops/sec (±1.11%) 6513 ops/sec (±1.54%) 0.98
get Collection 5726 ops/sec (±1.11%) 5892 ops/sec (±0.94%) 1.03
setLong 506 ops/sec (±0.38%) 520 ops/sec (±0.65%) 1.03
setLongWithMerge 198 ops/sec (±0.68%) 203 ops/sec (±0.25%) 1.03
setLongWithSimpleMerge 209 ops/sec (±0.40%) 216 ops/sec (±0.35%) 1.03
setSmallResponse 500x 902 ops/sec (±0.34%) 913 ops/sec (±0.13%) 1.01

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

Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.76%. Comparing base (262587c) to head (5bc8b3a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3164      +/-   ##
==========================================
- Coverage   98.76%   98.76%   -0.01%     
==========================================
  Files         132      132              
  Lines        2275     2270       -5     
  Branches      466      467       +1     
==========================================
- Hits         2247     2242       -5     
  Misses         17       17              
  Partials       11       11              

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

@ntucker ntucker force-pushed the mgr branch 2 times, most recently from 1d85e46 to 6ec96a0 Compare July 25, 2024 11:48
@ntucker ntucker merged commit ffea6fc into master Jul 25, 2024
26 checks passed
@ntucker ntucker deleted the mgr branch July 25, 2024 12:04
@github-actions github-actions bot mentioned this pull request Jul 25, 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