BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Angular 4.3 Brings New HttpClient and More

Angular 4.3 Brings New HttpClient and More

Leia em Português

This item in japanese

Lire ce contenu en français

Angular 4.3, the last 4.x release before Angular 5, is a drop-in replacement for previous versions and includes a number of new features, including a new HttpClient module, new router life cycle events, and more.

As mentioned, one of the major new features in Angular 4.3 is the HttpClient module, a complete rewrite of the old Http module bringing three significant improvements:

  • Responses provide access to a .json attribute that makes away with the requirement of explicit parsing the textual response.
  • A new generic mechanism to handle requests and responses using interceptors. To build an interceptor, you declare a class that implements the HttpInterceptor interface, then you chain it to the other interceptors responsible to handle the request or response.
  • Progress events to track both request upload and response download.

According to Angular contributor Cédric Exbrayat, migrating existing code to the new HttpClient module is fairly easy and mostly entails deleting code that is not required anymore.

Angular 4.3 also adds router-level events for GuardsCheck and Resolve, including ResolveStart, ResolveEnd, GuardsCheckStart, and GuardsCheckEnd. Those events are useful if you need to know when a resolver or a guard is run. Additionally, version 4.3 adds a new ::ng-deep alias for the /deep/ CSS selector, which can be used to force a style down to child components. This is mostly due to /deep/ being deprecated in Chrome and removed from all major browsers.

Finally, the ngc compiler has been modified to integrate with TypeScript 2.3 transformers concept. TypeScript transformers are plugins that are applied to the code compiled by tsc. With the changes in Angular 4.3, ngc is now a plugin called by tsc, rather than a wrapper around tsc. This should improve diagnostics and make it easier to refer to the exact line where type-checking fails in Angular source files.

You can read the full list of changes in Angular 4.3 for more details.

Rate this Article

Adoption
Style

BT