I am trying to take advantage of observables in angular2 and got confused on why should i use map()
over subscribe()
.
Suppose i am getting values f
Think map as a middleware which transforms the response.
this.http.get('http://172.17.40.41:8089/api/Master/GetAllCountry')
.map(r=>r.json())
.subscribe(result => {
// here result would have json object that was parsed by map handler...
},failurCallback,completeCallback)
subscribe is used to invoke the observable, please read a good doc on cold-vs-hot-observables