Our Blogs

Angular 4.3 Gets Better With HttpClient Module

July 28, 2017
245 Views
Angular 4.3 Gets Better With HttpClient Module
Angular 4.3 has been released with a wide range of features such as a new HttpClient module and refreshed router life cycle events. Touted as the last release before Angular 5, the newly launched HttpClient module is a complete rehash of the old Http module.

The HttpClient module included with the Angular 4.3 includes three main features. The responses provide access to a .JSON attribute, which compels the requirement of parsing the textual response explicitly. Moreover, the module includes a new mechanism to handle requests and responses using interceptors.

To create an interceptor, the class should be declared that implements the HttpInterceptor interface. After that, you will be able to chain it to the other interceptors that are mainly responsible for handling the request or response. Furthermore, the Angular 4.3 includes progress events to keep track of not only request upload but also response download.

According to Cedric Exbrayat, Angular contributor, the migration of existing code to the newly launched HttpClient module is an easy process. It involves deletion of the code that is not required. The latest release of Angular 4.3 also adds router-level events for GuardsCheck and Resolve, which includes ResolveStart, GuardsCheckStart, ResolveEnd, and GuardsCheckEnd. These events will be helpful if you need to know when a resolver or a guard is scheduled to run.

In addition to all the above features, the version 4.3 also brings in ::ng-deep alias for the  /deep/ CSS selector. You can use this to force a style down to child components. The main reason for this phenomenon is that /deep is deprecated in Chrome and also removed from all browsers.

The ngc compiler has bee changed in such a way to integrate the transformers concept included with TypeScript 2.3 version. The transformers are plugins that are automatically applied to the code compiled by tsc. With the release of Angular 4.3, the ngc is called a plugin by tsc instead of a mere wrapper, which ultimately improves the diagnostics.