Skip to content

Commit fddd1e2

Browse files
BREAKING CHANGE: Replace UrlRouterProvider/UrlRouter with just UrlRouter
The configuration functions from the provider object have been integrated into the normal UrlRouter object. The `UIRouter` object no longer has a `uriRouterProvider`, but the equivalent functions can be found on `uiRouter` One difference between the old functions on `urlRouterProvider` and the new ones on `uriRouter` is that new functions do not accept injectable functions.
1 parent 6c3ce5a commit fddd1e2

File tree

7 files changed

+210
-264
lines changed

7 files changed

+210
-264
lines changed

src/router.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @module core
44
*/ /** */
55
import { UrlMatcherFactory } from "./url/urlMatcherFactory";
6-
import { UrlRouterProvider, UrlRouter } from "./url/urlRouter";
6+
import { UrlRouter } from "./url/urlRouter";
77
import { TransitionService } from "./transition/transitionService";
88
import { ViewService } from "./view/view";
99
import { StateRegistry } from "./state/stateRegistry";
@@ -41,11 +41,9 @@ export class UIRouter {
4141

4242
urlMatcherFactory: UrlMatcherFactory = new UrlMatcherFactory();
4343

44-
urlRouterProvider: UrlRouterProvider = new UrlRouterProvider(this);
45-
4644
urlRouter: UrlRouter = new UrlRouter(this);
4745

48-
stateRegistry: StateRegistry = new StateRegistry(this.urlMatcherFactory, this.urlRouterProvider);
46+
stateRegistry: StateRegistry = new StateRegistry(this);
4947

5048
stateService = new StateService(this);
5149

@@ -92,7 +90,6 @@ export class UIRouter {
9290
this.globals.current = this.globals.$current.self;
9391

9492
this.disposable(this.transitionService);
95-
this.disposable(this.urlRouterProvider);
9693
this.disposable(this.urlRouter);
9794
this.disposable(this.stateRegistry);
9895
this.disposable(locationService);

src/state/stateQueueManager.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@ import { isString } from "../common/predicates";
44
import { StateDeclaration } from "./interface";
55
import { State } from "./stateObject";
66
import { StateBuilder } from "./stateBuilder";
7-
import { UrlRouterProvider } from "../url/urlRouter";
8-
import { StateRegistry, StateRegistryListener } from "./stateRegistry";
7+
import { StateRegistryListener, StateRegistry } from "./stateRegistry";
98
import { Disposable } from "../interface";
10-
import { UrlRuleFactory } from "../url/urlRule";
9+
import { UrlRouter } from "../url/urlRouter";
1110

1211
/** @internalapi */
1312
export class StateQueueManager implements Disposable {
1413
queue: State[];
1514

1615
constructor(
16+
private $registry: StateRegistry,
17+
private $urlRouter: UrlRouter,
1718
public states: { [key: string]: State; },
18-
public $registry: StateRegistry,
1919
public builder: StateBuilder,
20-
public $urlRouterProvider: UrlRouterProvider,
2120
public listeners: StateRegistryListener[]) {
2221
this.queue = [];
2322
}
@@ -100,7 +99,8 @@ export class StateQueueManager implements Disposable {
10099

101100
attachRoute(state: State) {
102101
if (state.abstract || !state.url) return;
103-
state._urlRule = new UrlRuleFactory(this.$urlRouterProvider._router).fromState(state);
104-
this.$urlRouterProvider.addRule(state._urlRule);
102+
103+
state._urlRule = this.$urlRouter.urlRuleFactory.fromState(state);
104+
this.$urlRouter.addRule(state._urlRule);
105105
}
106106
}

src/state/stateRegistry.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { State } from "./stateObject";
77
import { StateMatcher } from "./stateMatcher";
88
import { StateBuilder } from "./stateBuilder";
99
import { StateQueueManager } from "./stateQueueManager";
10-
import { UrlMatcherFactory } from "../url/urlMatcherFactory";
1110
import { StateDeclaration } from "./interface";
1211
import { BuilderFunction } from "./stateBuilder";
1312
import { StateOrName } from "./interface";
14-
import { UrlRouterProvider } from "../url/urlRouter";
13+
import { UrlRouter } from "../url/urlRouter";
1514
import { removeFrom } from "../common/common";
15+
import { UIRouter } from "../router";
1616

1717
/**
1818
* The signature for the callback function provided to [[StateRegistry.onStateRegistryEvent]].
@@ -31,14 +31,21 @@ export class StateRegistry {
3131
matcher: StateMatcher;
3232
private builder: StateBuilder;
3333
stateQueue: StateQueueManager;
34+
urlRouter: UrlRouter;
3435

3536
listeners: StateRegistryListener[] = [];
3637

37-
constructor(urlMatcherFactory: UrlMatcherFactory, private urlRouterProvider: UrlRouterProvider) {
38+
/** @internalapi */
39+
constructor(private _router: UIRouter) {
40+
this.urlRouter = _router.urlRouter;
3841
this.matcher = new StateMatcher(this.states);
39-
this.builder = new StateBuilder(this.matcher, urlMatcherFactory);
40-
this.stateQueue = new StateQueueManager(this.states, this, this.builder, urlRouterProvider, this.listeners);
42+
this.builder = new StateBuilder(this.matcher, _router.urlMatcherFactory);
43+
this.stateQueue = new StateQueueManager(this, _router.urlRouter, this.states, this.builder, this.listeners);
44+
this._registerRoot();
45+
}
4146

47+
/** @internalapi */
48+
private _registerRoot() {
4249
let rootStateDef: StateDeclaration = {
4350
name: '',
4451
url: '^',
@@ -139,7 +146,7 @@ export class StateRegistry {
139146
let deregistered = [state].concat(children).reverse();
140147

141148
deregistered.forEach(state => {
142-
this.urlRouterProvider.removeRule(state._urlRule);
149+
this.urlRouter.removeRule(state._urlRule);
143150
delete this.states[state.name];
144151
});
145152

0 commit comments

Comments
 (0)