Fixing our last failing test suite through refactoring

Unfortunately, our code now brings us into a scenario where our components are actually really hard to test appropriately. We have the code that has to fetch data off the backend mixed in with the code that initializes our components, as well as being mixed in with the behaviors when buttons are clicked! That's no good, so we'll need to fix this!

The good news is that the easiest way for us to fix this up doesn't require a mountain of effort; instead, it requires us to just move some of the code around in a way that would make it more extensible. The first operation we'll need to perform is moving all of our code that interacts with the backend into its own separate service library!

The service library pattern is a great pattern for when you need to lock down behaviors and interactions with external services into simpler APIs that make it easier for your code, or other people's code, to interact efficiently with a backend server!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset