HI WELCOME TO KANSIRIS
Showing posts with label angular. Show all posts
Showing posts with label angular. Show all posts

Observable retry on error

Leave a Comment
In this video we will how to resubscribe and retry an Observable if there is an error. Please change getEmployeeByCode() method in employee.service.ts file to return an Observable instead of a Promise as shown below. getEmployeeByCode(empCode: string): Observable<IEmployee> {     return this._http.get("http://localhost:24535/api/employees/" + empCode)        .

Angular promises vs observables

Leave a Comment
In Angular 2, to work with asynchronous data we can use either Promises or Observables. In our previous videos in this series, we discussed using both Observables and Promises. There are several differences between Promises and Observables. In this video let's discuss these differences. As a quick summary the differences are shown in the table below PromiseObservable Emits a single valueEmits multiple values over a period of time Not.

Promises in angular 2 example

Leave a Comment
In Angular we can use either Promises or Observables. By default the Angular Http service returns an Observable. To prove this, hover the mouse over the get() method of the Http service in employee.service.ts file. Notice from the intellisense, that it returns Observable<Response> To use Promises instead of Observables we will have to first make a change to the service to return a Promise instead of an Observable.In employee.service.ts file.