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

fix: separate out EntityMutationValidator #68

Merged
merged 3 commits into from
Jul 23, 2020

Conversation

wschurman
Copy link
Member

Why

Now that these are used for both triggers and validators, they should have a distinct name. I considered the following, but am open to others suggestions as well:

  • EntityMutationCallback - callbacks usually don't prevent something from running, so it didn't make sense for validation
  • EntityMutationHandler - handlers generally refer to overriding behavior of the framework rather than hooking into it.
  • EntityMutationExecutable- the method inside it is called executeAsync so this was the natural name
  • EntityMutationLambda - not really a JS term
  • EntityMutationHook - The term hook refers more to the when it is run rather than the what is run IMO.

How

TS renames.

Test Plan

yarn tsc

@wschurman wschurman requested review from ide and quinlanj July 23, 2020 18:59
@codecov
Copy link

codecov bot commented Jul 23, 2020

Codecov Report

Merging #68 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #68      +/-   ##
==========================================
+ Coverage   94.55%   94.57%   +0.02%     
==========================================
  Files          59       59              
  Lines        1488     1494       +6     
  Branches      167      168       +1     
==========================================
+ Hits         1407     1413       +6     
  Misses         79       79              
  Partials        2        2              
Flag Coverage Δ
#integration 94.57% <100.00%> (+0.02%) ⬆️
#unittest 94.57% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/entity/src/EntityCompanion.ts 100.00% <ø> (ø)
...s/entity/src/EntityMutationTriggerConfiguration.ts 100.00% <ø> (ø)
packages/entity/src/EntityCompanionProvider.ts 100.00% <100.00%> (ø)
packages/entity/src/EntityMutator.ts 98.02% <100.00%> (+0.03%) ⬆️
packages/entity/src/EntityMutatorFactory.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc4377d...3334412. Read the comment docs.

Copy link
Member

@ide ide left a comment

Choose a reason for hiding this comment

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

"Executable" sounds like a program. Here is a proposal:

Make two named types: a trigger type and a validator type. Both might be aliases for the same underlying type.

If we never intend to treat triggers and validators the same, they don't need to share an interface. In fact it might be desirable for them not to share and interface so that we don't imply that triggers and validators are interchangeable. Put another way, TS interfaces don't let us declare intent, and the intents behind triggers and validators differ.

I also think it's worth considering just using a plain function for the type unless there is a need to add more methods to the trigger interface.

packages/entity/src/EntityMutationExecutable.ts Outdated Show resolved Hide resolved
@wschurman
Copy link
Member Author

That's good reasoning for separating out the types. I updated the PR to reflect that.

As for the class vs function, see this comment: #65 (comment). I'll definitely consider making it a function in the future if usage seems to not make use of the benefits of a class, but having it as a class has turned out to be reasonably helpful for privacy policy rules.

@wschurman wschurman changed the title fix: rename EntityMutationTrigger -> EntityMutationExecutable fix: separate out EntityMutationValidator Jul 23, 2020
@wschurman wschurman merged commit 547a1ef into master Jul 23, 2020
@wschurman wschurman deleted the @wschurman/trigger-naming branch July 23, 2020 21:22
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.

3 participants