refactor(Http): remove HttpFactory

BREAKING CHANGE: HttpFactory is no longer available. 
    This factory provided a function alternative to the `request` method of the
    Http class, but added no real value. The additional factory required an
    additional IHttp interface, an odd way to inject while preserving type information
    (`@Inject(HttpFactory) http:IHttp`), and required additional documentation in the
    http module.

Closes #2564
This commit is contained in:
Jeff Cross
2015-06-23 20:46:03 -07:00
parent 55bf0e554f
commit 146dbf1270
4 changed files with 6 additions and 118 deletions

View File

@ -144,36 +144,3 @@ export class Http {
RequestMethods.HEAD, url)));
}
}
/**
*
* Alias to the `request` method of {@link Http}, for those who'd prefer a simple function instead
* of an object. In order to get TypeScript type information about the `HttpFactory`, the {@link
* IHttp} interface can be used as shown in the following example.
*
* #Example
*
* ```
* import {httpInjectables, HttpFactory, IHttp} from 'angular2/http';
* @Component({
* appInjector: [httpInjectables]
* })
* @View({
* templateUrl: 'people.html'
* })
* class MyComponent {
* constructor(@Inject(HttpFactory) http:IHttp) {
* http('people.json').subscribe(res => this.people = res.json());
* }
* }
* ```
**/
export function HttpFactory(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
return function(url: string | Request, options?: IRequestOptions) {
if (isString(url)) {
return httpRequest(backend, new Request(mergeOptions(defaultOptions, options, null, url)));
} else if (url instanceof Request) {
return httpRequest(backend, url);
}
};
}

View File

@ -55,33 +55,8 @@ export interface IResponse {
url: string;
totalBytes: number;
bytesLoaded: number;
blob(): any; // TODO: Blob
blob(): any; // TODO: Blob
arrayBuffer(): any; // TODO: ArrayBuffer
text(): string;
json(): Object;
}
/**
* Provides an interface to provide type information for {@link HttpFactory} when injecting.
*
* #Example
*
* ```
* * import {httpInjectables, HttpFactory, IHttp} from 'angular2/http';
* @Component({
* appInjector: [httpInjectables]
* })
* @View({
* templateUrl: 'people.html'
* })
* class MyComponent {
* constructor(@Inject(HttpFactory) http:IHttp) {
* http('people.json').subscribe(res => this.people = res.json());
* }
* }
* ```
*
*/
// Prefixed as IHttp because used in conjunction with Http class, but interface is callable
// constructor(@Inject(Http) http:IHttp)
export interface IHttp { (url: string, options?: IRequestOptions): EventEmitter }