Summary
In this chapter, we have spent some valuable time consolidating the existing source code of our WorldCities Angular app. We successfully implemented some optimizations and tweaks by making good use of the TypeScript class inheritance features, and we learned how to create base classes (superclasses) and derived classes (subclasses), thus making our source code more maintainable and DRY. At the same time, we took the chance to perform some bug fixing and add a couple of new features to our app’s UI.
Right after that, we refined the data fetching capabilities of our Angular app by switching from direct usage of Angular’s HttpClient
class in our components to a more versatile service-based approach. Eventually, we created CityService
and CountryService
– both extending a BaseService
abstract class – to deal with all the HTTP requests, thus paving the way for post-processing, error handling, retry logic, and more interesting stuff that will be introduced...