Converting an HTTP service Observable into a ZoneAwarePromise

In Angular 2, the RxJS asynchronous observables are first-class citizens and much of the core toolkit has been configured to rely upon them. Nonetheless, it is still valuable to be able to have conversion between them, especially since they have similar duties.

Tip

For more on RxJS Observables, refer to Chapter 5 , ReactiveX Observables, which covers them in depth.

Note

The code, links, and a live example of this are available at http://ngcookbook.herokuapp.com/0905/.

Getting ready

You'll begin with the following simplistic application:

[app/article.component.ts] import {Component} from '@angular/core'; import {Http} from '@angular/http'; @Component({ selector: 'article', template: ` <p></p> ...

Get Angular 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.