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: Remove _TYPE suffix from actionTypes #3244

Merged
merged 1 commit into from
Oct 13, 2024
Merged

enhance: Remove _TYPE suffix from actionTypes #3244

merged 1 commit into from
Oct 13, 2024

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Oct 13, 2024

Motivation

We already namespace actionTypes, so this is extra verbose for no reason.

Solution

Add actionTypes without _TYPE suffix

(Not breaking - we keep the old actionTypes name as well.)

import type { Manager, Middleware } from '@data-client/react';
import { actionTypes } from '@data-client/react';

export default class LoggingManager implements Manager {
  middleware: Middleware = controller => next => async action => {
    switch (action.type) {
      case actionTypes.SET_RESPONSE_TYPE:
        console.info(
          `${action.endpoint.name} ${JSON.stringify(action.response)}`,
        );
      default:
        return next(action);
    }
  };

  cleanup() {}
}
import type { Manager, Middleware } from '@data-client/react';
import { actionTypes } from '@data-client/react';

export default class LoggingManager implements Manager {
  middleware: Middleware = controller => next => async action => {
    switch (action.type) {
      case actionTypes.SET_RESPONSE:
        console.info(
          `${action.endpoint.name} ${JSON.stringify(action.response)}`,
        );
      default:
        return next(action);
    }
  };

  cleanup() {}
}

Copy link

changeset-bot bot commented Oct 13, 2024

🦋 Changeset detected

Latest commit: 11f88a9

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

This PR includes changesets to release 4 packages
Name Type
@data-client/test Patch
@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: 11f88a9 Previous: 43a955c Ratio
normalizeLong 524 ops/sec (±0.16%) 506 ops/sec (±0.49%) 0.97
infer All 9573 ops/sec (±0.82%) 9221 ops/sec (±1.74%) 0.96
denormalizeLong 346 ops/sec (±0.74%) 320 ops/sec (±2.82%) 0.92
denormalizeLong donotcache 891 ops/sec (±0.99%) 883 ops/sec (±0.58%) 0.99
denormalizeShort donotcache 500x 1368 ops/sec (±0.20%) 1391 ops/sec (±0.09%) 1.02
denormalizeShort 500x 975 ops/sec (±0.29%) 977 ops/sec (±1.09%) 1.00
denormalizeShort 500x withCache 4981 ops/sec (±0.21%) 4909 ops/sec (±0.15%) 0.99
denormalizeLong with mixin Entity 306 ops/sec (±0.43%) 294 ops/sec (±0.69%) 0.96
denormalizeLong withCache 6916 ops/sec (±0.20%) 6039 ops/sec (±0.15%) 0.87
denormalizeLong All withCache 6275 ops/sec (±0.15%) 6684 ops/sec (±0.15%) 1.07
denormalizeLong Query-sorted withCache 6254 ops/sec (±0.22%) 6568 ops/sec (±0.17%) 1.05
denormalizeLongAndShort withEntityCacheOnly 1528 ops/sec (±0.41%) 1514 ops/sec (±0.52%) 0.99
getResponse 5577 ops/sec (±0.40%) 5760 ops/sec (±0.26%) 1.03
getResponse (null) 5389657 ops/sec (±0.98%) 5362557 ops/sec (±0.74%) 0.99
getResponse (clear cache) 301 ops/sec (±0.25%) 292 ops/sec (±0.49%) 0.97
getSmallResponse 2633 ops/sec (±0.27%) 2661 ops/sec (±0.29%) 1.01
getSmallInferredResponse 2055 ops/sec (±0.13%) 2056 ops/sec (±0.71%) 1.00
getResponse Query-sorted 5446 ops/sec (±0.23%) 5529 ops/sec (±0.49%) 1.02
getResponse Collection 5741 ops/sec (±1.07%) 6136 ops/sec (±0.82%) 1.07
get Collection 5168 ops/sec (±0.94%) 5487 ops/sec (±1.31%) 1.06
setLong 524 ops/sec (±0.19%) 518 ops/sec (±0.19%) 0.99
setLongWithMerge 206 ops/sec (±0.33%) 203 ops/sec (±0.32%) 0.99
setLongWithSimpleMerge 216 ops/sec (±0.26%) 214 ops/sec (±0.29%) 0.99
setSmallResponse 500x 912 ops/sec (±0.49%) 912 ops/sec (±0.28%) 1

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

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.94%. Comparing base (43a955c) to head (11f88a9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3244   +/-   ##
=======================================
  Coverage   98.94%   98.94%           
=======================================
  Files         132      132           
  Lines        2270     2281   +11     
  Branches      467      467           
=======================================
+ Hits         2246     2257   +11     
  Misses         13       13           
  Partials       11       11           

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

@ntucker ntucker merged commit 109c922 into master Oct 13, 2024
26 checks passed
@ntucker ntucker deleted the action-types branch October 13, 2024 10:08
@github-actions github-actions bot mentioned this pull request Oct 13, 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