Skip to content

Commit

Permalink
refactor: Renamed some methods for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
vakrilov committed Oct 5, 2017
1 parent 1ad18cc commit f8dfb2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nativescript-angular/http-client/http-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getAbsolutePath(url: string, nsFileSystem: NSFileSystem): string
return url;
}

export function handleLocalRequest<T>(
export function processLocalFileRequest<T>(
url: string,
nsFileSystem: NSFileSystem,
successResponse: httpResponseFactory<T>,
Expand Down
8 changes: 4 additions & 4 deletions nativescript-angular/http-client/ns-http-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Observable } from "rxjs/Observable";

import { NSFileSystem } from "../file-system/ns-file-system";
import { isLocalRequest, handleLocalRequest } from "./http-utils";
import { isLocalRequest, processLocalFileRequest } from "./http-utils";

@Injectable()
export class NsHttpBackEnd extends HttpXhrBackend {
Expand All @@ -19,16 +19,16 @@ export class NsHttpBackEnd extends HttpXhrBackend {
let result: Observable<HttpEvent<any>>;

if (isLocalRequest(req.url)) {
result = this.handleLocalRequest(req.url);
result = this.handleLocalFileRequest(req.url);
} else {
result = super.handle(req);
}

return result;
}

private handleLocalRequest(url: string): Observable<HttpEvent<any>> {
return handleLocalRequest(
private handleLocalFileRequest(url: string): Observable<HttpEvent<any>> {
return processLocalFileRequest(
url,
this.nsFileSystem,
createSuccessResponse,
Expand Down
10 changes: 5 additions & 5 deletions nativescript-angular/http/ns-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { Observable } from "rxjs/Observable";
import "rxjs/add/observable/fromPromise";

import { isLocalRequest, handleLocalRequest } from "../http-client/http-utils";
import { isLocalRequest, processLocalFileRequest } from "../http-client/http-utils";

import { NSFileSystem } from "../file-system/ns-file-system";

Expand All @@ -34,7 +34,7 @@ export class NSHttp extends Http {
request(req: string | Request, options?: RequestOptionsArgs): Observable<Response> {
const urlString = typeof req === "string" ? req : req.url;
if (isLocalRequest(urlString)) {
return this.handleLocalRequest(urlString);
return this.requestLocalFile(urlString);
} else {
return super.request(req, options);
}
Expand All @@ -45,14 +45,14 @@ export class NSHttp extends Http {
*/
get(url: string, options?: RequestOptionsArgs): Observable<Response> {
if (isLocalRequest(url)) {
return this.handleLocalRequest(url);
return this.requestLocalFile(url);
} else {
return super.get(url, options);
}
}

private handleLocalRequest(url: string): Observable<Response> {
return handleLocalRequest(
private requestLocalFile(url: string): Observable<Response> {
return processLocalFileRequest(
url,
this.nsFileSystem,
createResponse,
Expand Down

0 comments on commit f8dfb2a

Please sign in to comment.