chore(http): remove RequestMethodsMap
This class was only added to do a reverse lookup of RequestMethods enum to get its name (i.e. "GET") for Dart. Since Dart is no longer supported by Http, method names can just be retrieved with TypeScript's support for enum name lookup, i.e. RequestMethods[RequestMethods.GET] === 'GET', making the RequestMethodsMap utility obsolete. Closes #2904
This commit is contained in:
parent
557d309377
commit
51285666d8
|
@ -1,5 +1,5 @@
|
|||
import {ConnectionBackend, Connection} from '../interfaces';
|
||||
import {ReadyStates, RequestMethods, RequestMethodsMap} from '../enums';
|
||||
import {ReadyStates, RequestMethods} from '../enums';
|
||||
import {Request} from '../static_request';
|
||||
import {Response} from '../static_response';
|
||||
import {ResponseOptions, BaseResponseOptions} from '../base_response_options';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {ConnectionBackend, Connection} from '../interfaces';
|
||||
import {ReadyStates, RequestMethods, RequestMethodsMap, ResponseTypes} from '../enums';
|
||||
import {ReadyStates, RequestMethods, ResponseTypes} from '../enums';
|
||||
import {Request} from '../static_request';
|
||||
import {Response} from '../static_response';
|
||||
import {ResponseOptions, BaseResponseOptions} from '../base_response_options';
|
||||
|
@ -27,14 +27,11 @@ export class XHRConnection implements Connection {
|
|||
private _xhr; // TODO: make type XMLHttpRequest, pending resolution of
|
||||
// https://github.com/angular/ts2dart/issues/230
|
||||
constructor(req: Request, browserXHR: BrowserXhr, baseResponseOptions?: ResponseOptions) {
|
||||
// TODO: get rid of this when enum lookups are available in ts2dart
|
||||
// https://github.com/angular/ts2dart/issues/221
|
||||
var requestMethodsMap = new RequestMethodsMap();
|
||||
this.request = req;
|
||||
this.response = new EventEmitter();
|
||||
this._xhr = browserXHR.build();
|
||||
// TODO(jeffbcross): implement error listening/propagation
|
||||
this._xhr.open(requestMethodsMap.getMethod(ENUM_INDEX(req.method)), req.url);
|
||||
this._xhr.open(RequestMethods[ENUM_INDEX(req.method)], req.url);
|
||||
this._xhr.addEventListener('load', (_) => {
|
||||
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
|
||||
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
|
||||
|
|
|
@ -46,13 +46,6 @@ export enum RequestMethods {
|
|||
PATCH
|
||||
}
|
||||
|
||||
// TODO: Remove this when enum lookups are available in ts2dart
|
||||
// https://github.com/angular/ts2dart/issues/221
|
||||
export class RequestMethodsMap {
|
||||
private _methods: List<string>;
|
||||
constructor() { this._methods = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD', 'PATCH']; }
|
||||
getMethod(method: number): string { return this._methods[method]; }
|
||||
}
|
||||
/**
|
||||
* All possible states in which a connection can be, based on
|
||||
* [States](http://www.w3.org/TR/XMLHttpRequest/#states) from the `XMLHttpRequest` spec, but with an
|
||||
|
|
Loading…
Reference in New Issue