chore: Make enum names consistent with TypeScript convention

BREAKING_CHANGE

Ts2Dart issue: https://github.com/angular/ts2dart/issues/270
TypeScript convention: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines
DartConvertion: https://www.dartlang.org/articles/style-guide/

Rename:

- NumberFormatStyle.DECIMAL => NumberFormatStyle.Decimal
- NumberFormatStyle.PERCENT => NumberFormatStyle.Percent
- NumberFormatStyle.CURRENCY => NumberFormatStyle.Currency
- RequestMethods.GET => RequestMethods.Get
- RequestMethods.POST => RequestMethods.Post
- RequestMethods.PUT => RequestMethods.Put
- RequestMethods.DELETE => RequestMethods.Delete
- RequestMethods.HEAD => RequestMethods.Head
- RequestMethods.PATCH => RequestMethods.Patch
- ReadyStates.UNSENT => ReadyStates.Unsent
- ReadyStates.OPEN => ReadyStates.Open
- ReadyStates.HEADERS_RECEIVED => ReadyStates.HeadersReceived
- ReadyStates.LOADING => ReadyStates.Loading
- ReadyStates.DONE => ReadyStates.Done
- ReadyStates.CANCELLED => ReadyStates.Canceled
This commit is contained in:
Misko Hevery
2015-08-26 13:40:12 -07:00
parent 465f7c95b0
commit 37b042b361
23 changed files with 206 additions and 209 deletions

View File

@ -19,12 +19,12 @@ export class JSONPConnection implements Connection {
constructor(req: Request, private _dom: BrowserJsonp,
private baseResponseOptions?: ResponseOptions) {
if (req.method !== RequestMethods.GET) {
if (req.method !== RequestMethods.Get) {
throw makeTypeError("JSONP requests must use GET request method.");
}
this.request = req;
this.response = new EventEmitter();
this.readyState = ReadyStates.LOADING;
this.readyState = ReadyStates.Loading;
this._id = _dom.nextRequestID();
_dom.exposeConnection(this._id, this);
@ -42,8 +42,8 @@ export class JSONPConnection implements Connection {
let script = this._script = _dom.build(url);
script.addEventListener('load', (event) => {
if (this.readyState === ReadyStates.CANCELLED) return;
this.readyState = ReadyStates.DONE;
if (this.readyState === ReadyStates.Cancelled) return;
this.readyState = ReadyStates.Done;
_dom.cleanup(script);
if (!this._finished) {
ObservableWrapper.callThrow(
@ -60,8 +60,8 @@ export class JSONPConnection implements Connection {
});
script.addEventListener('error', (error) => {
if (this.readyState === ReadyStates.CANCELLED) return;
this.readyState = ReadyStates.DONE;
if (this.readyState === ReadyStates.Cancelled) return;
this.readyState = ReadyStates.Done;
_dom.cleanup(script);
ObservableWrapper.callThrow(this.response, error);
});
@ -73,12 +73,12 @@ export class JSONPConnection implements Connection {
// Don't leak connections
this._finished = true;
this._dom.removeConnection(this._id);
if (this.readyState === ReadyStates.CANCELLED) return;
if (this.readyState === ReadyStates.Cancelled) return;
this._responseData = data;
}
dispose(): void {
this.readyState = ReadyStates.CANCELLED;
this.readyState = ReadyStates.Cancelled;
let script = this._script;
this._script = null;
if (isPresent(script)) {

View File

@ -34,7 +34,7 @@ export class MockConnection implements Connection {
constructor(req: Request) {
this.response = new EventEmitter();
this.readyState = ReadyStates.OPEN;
this.readyState = ReadyStates.Open;
this.request = req;
}
@ -42,8 +42,8 @@ export class MockConnection implements Connection {
* Changes the `readyState` of the connection to a custom state of 5 (cancelled).
*/
dispose() {
if (this.readyState !== ReadyStates.DONE) {
this.readyState = ReadyStates.CANCELLED;
if (this.readyState !== ReadyStates.Done) {
this.readyState = ReadyStates.Cancelled;
}
}
@ -62,10 +62,10 @@ export class MockConnection implements Connection {
*
*/
mockRespond(res: Response) {
if (this.readyState === ReadyStates.DONE || this.readyState === ReadyStates.CANCELLED) {
if (this.readyState === ReadyStates.Done || this.readyState === ReadyStates.Cancelled) {
throw new BaseException('Connection has already been resolved');
}
this.readyState = ReadyStates.DONE;
this.readyState = ReadyStates.Done;
ObservableWrapper.callNext(this.response, res);
ObservableWrapper.callReturn(this.response);
}
@ -91,7 +91,7 @@ export class MockConnection implements Connection {
*/
mockError(err?: Error) {
// Matches XHR semantics
this.readyState = ReadyStates.DONE;
this.readyState = ReadyStates.Done;
ObservableWrapper.callThrow(this.response, err);
ObservableWrapper.callReturn(this.response);
}

View File

@ -31,7 +31,7 @@ export class XHRConnection implements Connection {
this.response = new EventEmitter();
this._xhr = browserXHR.build();
// TODO(jeffbcross): implement error listening/propagation
this._xhr.open(RequestMethods[req.method], req.url);
this._xhr.open(RequestMethods[req.method].toUpperCase(), 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)