Web
Analytics
angular 5 forkjoin example - Tutorial

For Consultation : +91 9887575540

Stay Connected :

Fork joins in angular 

Fork joins in angular are used to help to handle the concurrent request. Sometimes various data is gathered from multiple sources in a single request and data must be displayed only when complete data successfully arrives on the webpage from all sources. Partial data must be discarded. Observables provide a method called forkJoin() to “wrap” multiple Observables, and make multiple concurrent http.get() requests. the operation will be failed if all requests are not completed. Subscriber method work as a handler for all observables.

In this example, customers.json and employees.json are two data sourced which will be read in a single request.

Step 1: Create two new files customers.json and employees.json and put into assets folder.





 

Step 2: Create new service myservice

two arrays with employee and customer data will be returned by gettwodata service method.

Step 3: Create new component forkjoinex

Step 4: Pass reference into app.component.html

Step 5: Pass reference of newly created service into app.module.ts then run program

ng serve –open

forkjoin in angular 5 example

forkjoin in angular 5 example

 



 

Select your currency