Skip to content

Commit 9313880

Browse files
fix(lazyLoad): Allow lazyLoad stateBuilder: Get lazyLoad fn from internal State object, not StateDeclaration
fix(lazyLoad): Fix `State.lazyLoad` type def
1 parent 7a03cac commit 9313880

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/hooks/lazyLoad.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {Transition} from "../transition/transition";
33
import {TransitionService} from "../transition/transitionService";
44
import {TransitionHookFn} from "../transition/interface";
55
import {StateDeclaration, LazyLoadResult} from "../state/interface";
6-
import {State} from "../state/stateObject";
76
import {services} from "../common/coreservices";
87
import { StateRule } from "../url/interface";
98

@@ -57,11 +56,11 @@ const lazyLoadHook: TransitionHookFn = (transition: Transition) => {
5756
}
5857

5958
// No matching state found, so let .sync() choose the best non-state match/otherwise
60-
router.urlRouter.sync();
59+
router.urlService.sync();
6160
}
6261

6362
let promises = transition.entering()
64-
.filter(state => !!state.lazyLoad)
63+
.filter(state => !!state.$$state().lazyLoad)
6564
.map(state => lazyLoadState(transition, state));
6665

6766
return services.$q.all(promises).then(retryTransition);
@@ -79,7 +78,7 @@ export const registerLazyLoadHook = (transitionService: TransitionService) =>
7978
* @returns A promise for the lazy load result
8079
*/
8180
export function lazyLoadState(transition: Transition, state: StateDeclaration): Promise<LazyLoadResult> {
82-
let lazyLoadFn = state.lazyLoad;
81+
let lazyLoadFn = state.$$state().lazyLoad;
8382

8483
// Store/get the lazy load promise on/from the hookfn so it doesn't get re-invoked
8584
let promise = lazyLoadFn['_promise'];

src/state/stateObject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class State {
8686
public onEnter: TransitionStateHookFn;
8787

8888
/** Prototypally inherits from [[StateDeclaration.lazyLoad]] */
89-
public lazyLoad: (transition: Transition) => Promise<StateDeclaration[]>;
89+
public lazyLoad: (transition: Transition, state: StateDeclaration) => Promise<StateDeclaration[]>;
9090

9191
/** Prototypally inherits from [[StateDeclaration.redirectTo]] */
9292
redirectTo: (

0 commit comments

Comments
 (0)