Skip to content

Commit 1a0ae71

Browse files
refactor(Globals): Switch from Globals to UIRouterGlobals for compat with ui-router-core 4.x
1 parent 81c931d commit 1a0ae71

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "State-based routing for Angular 2",
44
"version": "1.0.0-beta.4",
55
"scripts": {
6-
"clean": "shx rm -rf lib lib-esm _bundles _doc",
6+
"clean": "shx rm -rf lib lib-esm _bundles _dec",
77
"compile": "npm run clean && ngc",
88
"build": "npm run compile && webpack",
99
"test": "karma start config/karma.ng2.js",
@@ -51,7 +51,7 @@
5151
"module": "lib/index.js",
5252
"typings": "lib/index.d.ts",
5353
"dependencies": {
54-
"ui-router-core": "=3.1.1",
54+
"ui-router-core": "=4.0.0",
5555
"ui-router-rx": "=0.2.0"
5656
},
5757
"peerDependencies": {

src/directives/uiSref.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @ng2api @module directives */
22
/** */
3-
import { UIRouter, UIRouterGlobals, extend, Obj, TransitionOptions, Globals, TargetState } from "ui-router-core";
3+
import { UIRouter, UIRouterGlobals, extend, Obj, TransitionOptions, TargetState } from "ui-router-core";
44
import { Directive, Inject, Input, Optional, ElementRef, Renderer } from "@angular/core";
55
import { UIView, ParentUIViewInject } from "./uiView";
66
import { ReplaySubject } from "rxjs/ReplaySubject";
@@ -97,18 +97,21 @@ export class UISref {
9797
*/
9898
public targetState$ = new ReplaySubject<TargetState>(1);
9999

100-
/** @internalapi */
101-
private _emit: boolean = false;
102-
/** @internalapi */
103-
private _statesSub: Subscription;
100+
/** @internalapi */ private _emit: boolean = false;
101+
/** @internalapi */ private _statesSub: Subscription;
102+
/** @internalapi */ private _router: UIRouter;
103+
/** @internalapi */ public parent: ParentUIViewInject;
104+
/** @internalapi */ private _anchorUISref: AnchorUISref;
104105

105106
constructor(
106-
/** @internalapi */ private _router: UIRouter,
107-
/** @internalapi */ @Inject(UIView.PARENT_INJECT) public parent: ParentUIViewInject,
108-
/** @internalapi */ @Optional() private _anchorUISref: AnchorUISref,
109-
@Inject(Globals) _globals: UIRouterGlobals
107+
_router: UIRouter,
108+
@Inject(UIView.PARENT_INJECT) parent: ParentUIViewInject,
109+
@Optional() _anchorUISref: AnchorUISref
110110
) {
111-
this._statesSub = _globals.states$.subscribe(() => this.update())
111+
this._router = _router;
112+
this.parent = parent;
113+
this._anchorUISref = _anchorUISref;
114+
this._statesSub = _router.globals.states$.subscribe(() => this.update())
112115
}
113116

114117
/** @internalapi */

src/directives/uiSrefStatus.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Transition} from "ui-router-core";
66
import {TargetState} from "ui-router-core";
77
import {State} from "ui-router-core";
88
import {anyTrueR, tail, unnestR, Predicate} from "ui-router-core";
9-
import {Globals, UIRouterGlobals} from "ui-router-core";
9+
import {UIRouterGlobals} from "ui-router-core";
1010
import {Param} from "ui-router-core";
1111
import {PathFactory} from "ui-router-core";
1212
import {Subscription} from "rxjs/Subscription";
@@ -184,11 +184,12 @@ export class UISrefStatus {
184184
/** The current status */
185185
status: SrefStatus;
186186

187-
private _subscription: Subscription;
188-
private _srefChangesSub: Subscription;
189-
private _srefs$: BehaviorSubject<UISref[]>;
190-
191-
constructor(@Inject(Globals) private _globals: UIRouterGlobals) {
187+
/** @internalapi */ private _subscription: Subscription;
188+
/** @internalapi */ private _srefChangesSub: Subscription;
189+
/** @internalapi */ private _srefs$: BehaviorSubject<UISref[]>;
190+
/** @internalapi */ private _globals: UIRouterGlobals;
191+
constructor(_globals: UIRouterGlobals) {
192+
this._globals = _globals;
192193
this.status = Object.assign({}, inactiveStatus);
193194
}
194195

src/providers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
import { Injector, Provider } from "@angular/core";
8989
import {
9090
UIRouter, PathNode, StateRegistry, StateService, TransitionService, UrlMatcherFactory, UrlRouter, ViewService,
91-
UrlService, Globals, services, Resolvable, NATIVE_INJECTOR_TOKEN
91+
UrlService, UIRouterGlobals, services, Resolvable, NATIVE_INJECTOR_TOKEN
9292
} from "ui-router-core";
9393
import { UIView, ParentUIViewInject } from "./directives/uiView";
9494
import { ng2ViewsBuilder, Ng2ViewConfig } from "./statebuilders/views";
@@ -192,7 +192,7 @@ export const _UIROUTER_SERVICE_PROVIDERS: Provider[] = [
192192
{ provide: UrlService, useFactory: fnUrlService, deps: [UIRouter]},
193193
{ provide: ViewService, useFactory: fnViewService, deps: [UIRouter]},
194194
{ provide: StateRegistry, useFactory: fnStateRegistry, deps: [UIRouter]},
195-
{ provide: Globals, useFactory: fnGlobals, deps: [UIRouter]},
195+
{ provide: UIRouterGlobals, useFactory: fnGlobals, deps: [UIRouter]},
196196
];
197197

198198
/**

0 commit comments

Comments
 (0)