Skip to content

Commit 5128566

Browse files
rixrixjeffbcross
authored andcommitted
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 angular#2904
1 parent 557d309 commit 5128566

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

modules/angular2/src/http/backends/jsonp_backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {ConnectionBackend, Connection} from '../interfaces';
2-
import {ReadyStates, RequestMethods, RequestMethodsMap} from '../enums';
2+
import {ReadyStates, RequestMethods} from '../enums';
33
import {Request} from '../static_request';
44
import {Response} from '../static_response';
55
import {ResponseOptions, BaseResponseOptions} from '../base_response_options';

modules/angular2/src/http/backends/xhr_backend.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {ConnectionBackend, Connection} from '../interfaces';
2-
import {ReadyStates, RequestMethods, RequestMethodsMap, ResponseTypes} from '../enums';
2+
import {ReadyStates, RequestMethods, ResponseTypes} from '../enums';
33
import {Request} from '../static_request';
44
import {Response} from '../static_response';
55
import {ResponseOptions, BaseResponseOptions} from '../base_response_options';
@@ -27,14 +27,11 @@ export class XHRConnection implements Connection {
2727
private _xhr; // TODO: make type XMLHttpRequest, pending resolution of
2828
// https://github.com/angular/ts2dart/issues/230
2929
constructor(req: Request, browserXHR: BrowserXhr, baseResponseOptions?: ResponseOptions) {
30-
// TODO: get rid of this when enum lookups are available in ts2dart
31-
// https://github.com/angular/ts2dart/issues/221
32-
var requestMethodsMap = new RequestMethodsMap();
3330
this.request = req;
3431
this.response = new EventEmitter();
3532
this._xhr = browserXHR.build();
3633
// TODO(jeffbcross): implement error listening/propagation
37-
this._xhr.open(requestMethodsMap.getMethod(ENUM_INDEX(req.method)), req.url);
34+
this._xhr.open(RequestMethods[ENUM_INDEX(req.method)], req.url);
3835
this._xhr.addEventListener('load', (_) => {
3936
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
4037
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)

modules/angular2/src/http/enums.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ export enum RequestMethods {
4646
PATCH
4747
}
4848

49-
// TODO: Remove this when enum lookups are available in ts2dart
50-
// https://github.com/angular/ts2dart/issues/221
51-
export class RequestMethodsMap {
52-
private _methods: List<string>;
53-
constructor() { this._methods = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD', 'PATCH']; }
54-
getMethod(method: number): string { return this._methods[method]; }
55-
}
5649
/**
5750
* All possible states in which a connection can be, based on
5851
* [States](http://www.w3.org/TR/XMLHttpRequest/#states) from the `XMLHttpRequest` spec, but with an

0 commit comments

Comments
 (0)