-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Replace all Hooks with appEvents #4915
Conversation
using `appEvents`. Consistent new args passed.
and remove related hooks
related to creation of the default owner user on startup
with "getPageSitemapItems" functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look at the conflicted file (imports/plugins/core/hydra-oauth/server/init.js), but there didn't seem to be much info on what was in conflict. Perhaps it's the whole file that was deleted and then re-added here? Can you please take a look?
That comment might actually be referring to MethodHooks, but I don't see those being used anymore either, so I can remove those and the comment, too.
Yes! I was thinking of doing that, too. I'm still planning to go through this once more and document all of the changes in a before/after table. So I'll verify they are all using object arg at that time. I'm leaning toward also adding a way to define a SimpleSchema for each event, which we can then validate the objects. That way nobody can mess up. |
@kieckhafer This is updated and ready for another look. Note the table I added to the PR description, which shows how each event has changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most everything looks good. I was able to create orders, accounts, update accounts, process orders, update products, publish, etc. Anything that seemed like it touched a hook, I had no issue with.
I came across one issue, however I don't think it's related to this PR, so I've created an issue for it to look into ( #4931 ). My guess is this was introduced in #4908 and missed during that review (by me).
Impact: breaking
Type: feature
Changes
Hooks
usage with the newerappEvents
. This is a step on the path to heavier reliance on events as the primary communication mechanism among Reaction plugins and services.MethodHooks
feature.appEvents
events to emit with a different argument signature. All events now emit a single object. This makes it easier to add and remove properties without additional breaking changes in the future.Arguments: userId, accountId
Arguments: { account, createdBy, isFirstOwnerAccount }
Arguments: userId, { accountId, updatedFields }
Arguments: { account, updatedBy, updatedFields }
Arguments: userId, accountId
Arguments: { account, deletedBy }
Arguments: { email, userId }
Arguments: { variant, deletedBy }
Arguments: product
Arguments: { product, deletedBy }
Arguments: { _id, field, value }
Arguments: product, catalogProduct
Arguments: { catalogProduct, product }
Arguments: { order, updatedBy }
Arguments: NONE
Arguments: NONE
Arguments: NONE
Arguments: NONE
Deprecated. Do not use in new code. Put your code directly in a non-Meteor plugin startup function instead.
Arguments: { job, sendEmailCompleted, sendEmailFailed }
Arguments: { createdBy, shop }
Arguments: { createdBy, mediaRecord }
Arguments: { createdBy, mediaRecord }
Arguments: { createdBy, mediaRecord }
Arguments: { approvedBy, order }
Arguments: { cancelledBy, order, returnToStock }
Arguments: { capturedBy, order, payment }
Arguments: { createdBy, order }
Arguments: { createdBy, notification }
Arguments: user
isFirstOwnerAccount
set totrue
Arguments: order, options
Arguments: order
afterOrderUpdate
.Arguments: product
Arguments: product, { userId, modifier }
Arguments: productId, { modifier }
Arguments: product, { userId }
Arguments: userId, productId
Arguments: NONE
Arguments: NONE
Arguments: object
Arguments: user, options
Arguments: options
Arguments: options
Arguments: orderId
afterOrderUpdate
.Arguments: orderId
afterOrderUpdate
.Arguments: orderId
afterOrderUpdate
.Arguments: urls
Breaking changes
This does not break anything within the core and included plugins, but
@reactioncommerce/hooks
package, you will need to update or obtain updated versions that usecontext.appEvents
instead.MethodHooks
, update it to implement those hooks a different way.appEvents
consumed and emitted by custom plugins. Update expected and emitted arguments. See the table above.Testing
Look through code and test anything that looks like it might be affected by these changes, for example, anything that runs based on consuming an event.