Could somebody explain me two things:
- Difference between Cold or Hot http requests?
- Are http requests in Angular 2 Cold or Hot?
Could somebody explain me two things:
In Angular, http requests made from the Http service are cold.
Cold, in this context, means that the http request is not made until someone subscribes to the observable returned from Http.get, Http.post etc. Also, each subscription to an http observable will cause a different http request to be fired. This is because, as a cold observable, the http observable is responsible for creating its producer (i.e. the Ajax request) on subscription, and each subscription will create a separate producer of values (i.e. separate Ajax requests).
Thoughtram has a detailed article on hot vs cold observables.
Its cold since any request only starts producing value first when you subscribe to it. Without running
http.get().subscribe((response) => ...)
No request will be send to the server. http.get()
alone is just an object.