There are two things that can be injected in order to perform Http requests, Http or HttpFactory. Http is a class with the primary method of request, plus some shortcut methods like get, post, etc. HttpFactory is a function equivalent to Http.request.
I think having HttpFactory adds more concepts/complexity than is warranted, and I'd like to remove it. For one, it requires two more pages of documentation. One page to document the factory itself, and another to document the IHttp interface that exists solely to provide type information for the factory.
// Factory
import {HttpFactory, IHttp} from 'angular2/http';
class MyComponent {
constructor(@Inject(HttpFactory) http:IHttp) {
http('angular.json').subscribe(ng => this.angular = ng);
}
}
// Class
import {Http} from 'angular2/http';
class MyComponent {
constructor(http:Http) {
http.request('angular.json').subscribe(ng => this.angular = ng);
}
}
The idea of having a simple callable function instead of calling a class method is nice, but I think the trade-off of additional concepts isn't worth the overhead.
@Blesh @caitp what do you two think?
There are two things that can be injected in order to perform Http requests,
HttporHttpFactory. Http is a class with the primary method ofrequest, plus some shortcut methods likeget,post, etc.HttpFactoryis a function equivalent toHttp.request.I think having
HttpFactoryadds more concepts/complexity than is warranted, and I'd like to remove it. For one, it requires two more pages of documentation. One page to document the factory itself, and another to document theIHttpinterface that exists solely to provide type information for the factory.The idea of having a simple callable function instead of calling a class method is nice, but I think the trade-off of additional concepts isn't worth the overhead.
@Blesh @caitp what do you two think?