News for hackers. Stuff that matters.
Re:How I made a website with Svelte by rileymat2 on Saturday December 28, 2019 @02:21PM (#21901055)
Interestingly, they explain some of the reasoning behind the extra info in the docs.

WHY WRITE A SERVICE? This example is so simple that it is tempting to write the Http.get() inside the component itself and skip the service. In practice, however, data access rarely stays this simple. You typically need to post-process the data, add error handling, and maybe some retry logic to cope with intermittent connectivity. The component quickly becomes cluttered with data access minutia. The component becomes harder to understand, harder to test, and the data access logic can't be re-used or standardized. That's why it's a best practice to separate presentation of data from data access by encapsulating data access in a separate service and delegating to that service in the component, even in simple cases like this one.

There are no comments on this comment yet.