Skip to content

Use cases for custom services? #2435

Answered by daffl
gustojs asked this question in Q&A
Aug 22, 2021 · 4 comments · 3 replies
Discussion options

You must be logged in to vote

Personally I don't think I ever found a custom service unnecessary later but I've seen more than a few example where what is done in hooks should really be a custom or customized (extended) service instead. This is part of the reason why I added the Hooks vs. extending services section to the guide.

For example, if you end up setting context.result in hooks a lot (other than e.g. a generic caching system) it might be worth customizing the service instead. The most extreme example I've seen was a custom service method simply returning true which never got hit due to a hook around it always setting context.result. That hook should have really been the service method itself.

I have a feeling…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by gustojs
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@gustojs
Comment options

@bwgjoseph
Comment options

Comment options

You must be logged in to vote
1 reply
@bwgjoseph
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants