Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks

Home Page:https://atmospherejs.com/matb33/collection-hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If multiple hooks are defined with the same type on the same collection, which of them gets run first, and which second...

dongzhi-yang opened this issue · comments

Hi,
Suppose I have 5 different after.insert hooks defined on the same collection. In what order will they run? Is there a way I can controller this?

Thanks

commented

They are gonna be run in the same order they get loaded.
You can control the order controlling the loading order of the files that declarethem, or controlling the loading order of the packages they are part of.

If you have all of them in the same file, they will be run in the order you declare them in that file.

Anyway, if you are writing hooks that are affecting each other, you should maybe reconsider that. Hooks should be independent and if possible. If you want a hook to run after the other want, maybe you should just put them together in the same function :smile

I hope that helps.

I close this issue because i think the problem is solved 😄