Skip to content

Commit 59d39fa

Browse files
committed
(chore) Code cleanup
1 parent 19591c6 commit 59d39fa

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

src/localize-router.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NgModule, ModuleWithProviders, APP_INITIALIZER, Provider } from '@angular/core';
22
import { HttpModule, Http } from '@angular/http';
3-
import { LocalizeRouterService, RAW_ROUTES, parserInitializer } from './localize-router.service';
4-
import { LocalizeParser, StaticParserLoader } from './localize-router.parser';
3+
import { LocalizeRouterService } from './localize-router.service';
4+
import { LocalizeParser, RAW_ROUTES, StaticParserLoader, parserInitializer } from './localize-router.parser';
55
import { RouterModule, Routes } from '@angular/router';
66
import { LocalizeRouterPipe } from './localize-router.pipe';
77
import { TranslateModule, TranslateService } from 'ng2-translate';

src/localize-router.parser.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Http, Response } from '@angular/http';
2+
import { OpaqueToken } from '@angular/core';
23
import { Routes, Route } from '@angular/router';
34
import { TranslateService } from 'ng2-translate';
45
import { Observable } from 'rxjs/Observable';
@@ -9,6 +10,12 @@ import 'rxjs/add/operator/toPromise';
910

1011
const LOCALIZE_LOCAL_STORAGE = 'LOCALIZE_LOCAL_STORAGE';
1112

13+
/**
14+
* Static provider for keeping track of routes
15+
* @type {OpaqueToken}
16+
*/
17+
export const RAW_ROUTES = new OpaqueToken('RAW_ROUTES');
18+
1219
/**
1320
* Config interface
1421
*/
@@ -302,3 +309,25 @@ export class StaticParserLoader extends LocalizeParser {
302309
});
303310
}
304311
}
312+
313+
314+
/**
315+
* Pre-loading helper functions
316+
* Necessary evil for AOT
317+
* @param parser
318+
* @param routes
319+
* @returns {any}
320+
*/
321+
export function parserInitializer(parser: LocalizeParser, routes: any) {
322+
loadRoutes.prototype.parser = parser;
323+
loadRoutes.prototype.routes = routes.reduce(concatArrays);
324+
return loadRoutes;
325+
}
326+
327+
export function concatArrays(a: Array<any>, b: Array<any>): Array<any> {
328+
return a.concat(b);
329+
}
330+
331+
export function loadRoutes() {
332+
return loadRoutes.prototype.parser.load(loadRoutes.prototype.routes);
333+
}

src/localize-router.service.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import { Injectable, OpaqueToken } from '@angular/core';
1+
import { Injectable } from '@angular/core';
22
import { Router, NavigationStart, ActivatedRouteSnapshot } from '@angular/router';
33
import { Observable } from 'rxjs/Observable';
44
import { Subject } from 'rxjs/Subject';
55
import 'rxjs/add/observable/forkJoin';
66

77
import { LocalizeParser } from './localize-router.parser';
88

9-
/**
10-
* Static provider for keeping track of routes
11-
* @type {OpaqueToken}
12-
*/
13-
export const RAW_ROUTES = new OpaqueToken('RAW_ROUTES');
14-
159
/**
1610
* Localization service
1711
* modifyRoutes
@@ -110,24 +104,3 @@ export class LocalizeRouterService {
110104
};
111105
}
112106
}
113-
114-
/**
115-
* Pre-loading helper functions
116-
* Necessary evil for AOT
117-
* @param parser
118-
* @param routes
119-
* @returns {any}
120-
*/
121-
export function parserInitializer(parser: LocalizeParser, routes: any) {
122-
loadRoutes.prototype.parser = parser;
123-
loadRoutes.prototype.routes = routes.reduce(concatArrays);
124-
return loadRoutes;
125-
}
126-
127-
export function concatArrays(a: Array<any>, b: Array<any>): Array<any> {
128-
return a.concat(b);
129-
}
130-
131-
export function loadRoutes() {
132-
return loadRoutes.prototype.parser.load(loadRoutes.prototype.routes);
133-
}

0 commit comments

Comments
 (0)