Rxjs - Forkjoin


forkJoin() operator allows to take a list of Observable and execute them in parallel.Once every Observable emits a value , forkJoin  will emit a single Observable value containing a list of all callback values from the Observable in the list.
The advantage of fork join is that we are able to know the list that is populated by diffrent api call's callback method and we can perform specific operations.In common scenario, we subscribe to that callback and we can use that list.The problem is that we subscribe to that method.It creates a waiting time for another api call .Using forkjoin we make different api calls using different threads at the same time.
Only problem with forkjoin is that if even one callback function fails then we wont get any data and if one takes too much time then results will be emitted after a long time as forkjoin emits a single Observable value if all passes.

Comments