DEV Community

Discussion on: What are services in Vue?

Collapse
 
vonziu profile image
Konrad Stącel

Generally speaking the idea of services is universal across languages and architectures. This unit of work should handle most of the logic, leaving controllers to do as little heavy lifting as possible( In Vue scenario: Let Vue handle synchronization between DOM and javascript, rest can be done in service). It's much easier to reuse. Testing plain old javascript is much easier to test than Vue component, thus: If you don't need Vue magic, let's create a service - that is my approach.
I even suggest to use factory pattern to create new data from old data. I've been playing with repository pattern too, but it seemed like kinda of overkill.