Skip to content

Commit

Permalink
chore(test): Eagerly bind the urlService in the TestPlugin.
Browse files Browse the repository at this point in the history
feat(UrlService): allow eager or lazy binding of location objects during construction
  • Loading branch information
christopherthielen committed Jan 5, 2017
1 parent 1ca93d0 commit 7e0a8af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/url/urlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ export class UrlService implements LocationServices, UrlSyncApi {
private router: UIRouter;

/** @hidden */
constructor(router: UIRouter) {
constructor(router: UIRouter, lateBind = true) {
this.router = router;
this.rules = {} as any;
this.config = {} as any;

// proxy function calls from UrlService to the LocationService/LocationConfig
const locationServices = () => router.locationService;
createProxyFunctions(locationServices, this, locationServices, locationServicesFns, true);
createProxyFunctions(locationServices, this, locationServices, locationServicesFns, lateBind);

const locationConfig = () => router.locationConfig;
createProxyFunctions(locationConfig, this.config, locationConfig, locationConfigFns, true);
createProxyFunctions(locationConfig, this.config, locationConfig, locationConfigFns, lateBind);

const umf = () => router.urlMatcherFactory;
createProxyFunctions(umf, this.config, umf, umfFns);
Expand Down
3 changes: 3 additions & 0 deletions test/_testingPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UIRouter } from "../src/router";
import { UIRouterPluginBase } from "../src/interface";
import * as vanilla from "../src/vanilla";
import { UrlService } from "../src/url/urlService";

export class TestingPlugin extends UIRouterPluginBase {
name: string = 'testing';
Expand All @@ -11,6 +12,8 @@ export class TestingPlugin extends UIRouterPluginBase {
super();
router.plugin(vanilla.servicesPlugin);
router.plugin(vanilla.memoryLocationPlugin);
// bind the location proxy functions immediately
router.urlService = new UrlService(router, false);

this.addErrorLoopHandler();

Expand Down

0 comments on commit 7e0a8af

Please sign in to comment.