From 7e0a8af6d975459987a8bfa9063afdb54c0b22ec Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Thu, 5 Jan 2017 10:21:00 -0600 Subject: [PATCH] chore(test): Eagerly bind the urlService in the TestPlugin. feat(UrlService): allow eager or lazy binding of location objects during construction --- src/url/urlService.ts | 6 +++--- test/_testingPlugin.ts | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/url/urlService.ts b/src/url/urlService.ts index b2e17360..fdf638b1 100644 --- a/src/url/urlService.ts +++ b/src/url/urlService.ts @@ -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); diff --git a/test/_testingPlugin.ts b/test/_testingPlugin.ts index 974072b4..83868fcd 100644 --- a/test/_testingPlugin.ts +++ b/test/_testingPlugin.ts @@ -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'; @@ -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();