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
Configure hook order? #6799
Comments
@alxndrsn Thanks for posting! We'll take a look as soon as possible. In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly. For help with questions about Sails, click here. |
Hi @alxndrsn! Unfortunately, as of Sails v1.0, the load order of custom hooks is not guaranteed (see the relevant documentation). We take user interest into consideration when planning updates to Sails, so this might be a feature to include in a future version. I'll leave this open in case anybody else has thoughts or suggestions related to this topic. 🌊 |
@alxndrsn You might be able to get away with waiting for the ORM hook to load, doing what you need, then forcing it to reload. Depends on your use case. I do something like the following very cut-down example in the sails.after('hook:orm:loaded', () => {
// Do some hacky voodoo and retrofit/tweak models
sails.hooks.orm.reload((err) => { /* handle explosions */ })
}) Actually calling Edit: https://github.com/balderdashy/sails-hook-orm#sailshooksormreload says you shouldn't do this 😆 |
@MadisonHicks that's a shame, but thanks for clarifying |
This is how I propose to incorporate this feature in the next release, and would really appreciate it [and believe many others would too]. DescriptionDefine an additional input when one can input change the automatic naming convention by sails: (
Here, ReasoningUse-case | generally speaking, defining an order for hooks is quite complicated for big projects. Nobody can really keep tracks of what should come after what and why! However, there are packages which need to be loaded prior to others: ORM, View Engines, etc. Hence, it is best to define an "order" hierarchy instead of requesting the developer to provide the order via an array or json or etc. Precedent | This is practically the "hack" that @emahuni suggests in #2517. Development | Though, I don't know how the Sails core does it, but I do believe that this is going to be quite easy to implement. PS. Thanks for developing, maintaining and keeping Sails relevant. Hope one day Sails would be what Laravel or Rails are to their respective languages. |
Hello @alxndrsn & @captainhusaynpinguin, Sails handles hook order in |
I'd like to define (and potentially release) a couple of hooks which modify the models and associated functions created by
sails-hook-orm
. Is there a way to configure the order of hook loading/execution?I've noticed a couple of issues asking the same question (#2517, #4338), but no response and nothing in the hooks docs (https://sailsjs.com/documentation/concepts/extending-sails/hooks/hook-specification).
The text was updated successfully, but these errors were encountered: