@@ -9,19 +9,17 @@ import {HookRegistry, matchState} from "./hookRegistry";
9
9
import HookBuilder from "./hookBuilder" ;
10
10
import { RejectFactory } from "./rejectFactory" ;
11
11
12
- import { IResolvePath , ITransPath } from "../path/interface" ;
12
+ import { ITransPath } from "../path/interface" ;
13
13
import PathFactory from "../path/pathFactory" ;
14
14
15
- import ResolveContext from "../resolve/resolveContext" ;
16
- import PathContext from "../resolve/pathContext" ;
17
-
18
15
import TargetState from "../state/targetState" ;
19
- import { IState , IStateDeclaration , IStateViewConfig } from "../state/interface" ;
16
+ import { IState , IStateDeclaration } from "../state/interface" ;
20
17
21
18
import ParamValues from "../params/paramValues" ;
22
19
23
- import { extend , flatten , forEach , identity , isEq , isObject , map , not , prop , toJson , unnest , val ,
24
- pairs , abstractKey } from "../common/common" ;
20
+ import { ViewConfig } from "../view/view" ;
21
+
22
+ import { extend , flatten , forEach , identity , isEq , isObject , not , prop , toJson , val , abstractKey } from "../common/common" ;
25
23
26
24
let transitionCount = 0 , REJECT = new RejectFactory ( ) ;
27
25
const stateSelf : ( _state : IState ) => IStateDeclaration = prop ( "self" ) ;
@@ -222,29 +220,13 @@ export class Transition implements IHookRegistry {
222
220
return this . _treeChanges . retained . states ( ) . map ( stateSelf ) ;
223
221
}
224
222
225
- // TODO
226
- context ( pathname : string , state : IState ) : PathContext {
227
- let path = this . _treeChanges [ pathname ] . pathFromRootTo ( state ) ;
228
- return new PathContext ( new ResolveContext ( path ) , state , runtime . $injector , this . _options ) ;
229
- }
230
-
231
223
/**
232
- * Returns a list of StateViewConfig objects;
233
- * Returns one StateViewConfig for each view in each state in a named path of the transition's tree changes
224
+ * Returns a list of ViewConfig objects for a given path. Returns one ViewConfig for each view in
225
+ * each state in a named path of the transition's tree changes. Optionally limited to a given state in that path.
234
226
*/
235
- views ( pathname : string = "entering" , contextPathname : string = "to" ) {
236
- let path : IResolvePath = this . _treeChanges [ pathname ] ;
237
- let states : IState [ ] = path . states ( ) ;
238
- let params : ParamValues = this . params ( ) ;
239
-
240
- return unnest ( map ( states , ( state : IState ) => {
241
- let context = state ;
242
- let locals : PathContext = this . context ( contextPathname , state ) ;
243
- const makeViewConfig = ( [ rawViewName , viewDeclarationObj ] ) => { return < IStateViewConfig > {
244
- rawViewName, viewDeclarationObj, context, locals, params} ;
245
- } ;
246
- return pairs ( state . views ) . map ( makeViewConfig ) ;
247
- } ) ) ;
227
+ views ( pathname : string = "entering" , state ?: IState ) : ViewConfig [ ] {
228
+ let path = this . _treeChanges [ pathname ] ;
229
+ return state ? path . nodeForState ( state ) . views : flatten ( path . nodes ( ) . map ( prop ( "views" ) ) ) ;
248
230
}
249
231
250
232
/**
0 commit comments