@@ -175,7 +175,7 @@ export function routerReducer<
175
175
176
176
export interface StoreRouterConfig {
177
177
stateKey ?: string ;
178
- serializer ?: new ( ) => RouterStateSerializer ;
178
+ serializer ?: new ( ... args : any [ ] ) => RouterStateSerializer ;
179
179
/**
180
180
* By default, ROUTER_NAVIGATION is dispatched before guards and resolvers run.
181
181
* Therefore, the action could run too soon, for example
@@ -200,34 +200,16 @@ export const ROUTER_CONFIG = new InjectionToken(
200
200
export const DEFAULT_ROUTER_FEATURENAME = 'router' ;
201
201
202
202
export function _createRouterConfig (
203
- config : StoreRouterConfig | StoreRouterConfigFunction
203
+ config : StoreRouterConfig
204
204
) : StoreRouterConfig {
205
- let _config : StoreRouterConfig ;
206
-
207
- if ( typeof config === 'function' ) {
208
- _config = config ( ) ;
209
- } else {
210
- _config = config || { } ;
211
- }
212
-
213
205
return {
214
206
stateKey : DEFAULT_ROUTER_FEATURENAME ,
215
207
serializer : DefaultRouterStateSerializer ,
216
208
navigationActionTiming : NavigationActionTiming . PreActivation ,
217
- ..._config ,
209
+ ...config ,
218
210
} ;
219
211
}
220
212
221
- export function _createSerializer (
222
- config : StoreRouterConfig
223
- ) : RouterStateSerializer {
224
- // This function gets handed a complete config-object from _createRouterConfig,
225
- // so we know the serializer property exists
226
- return new config . serializer ! ( ) ;
227
- }
228
-
229
- export type StoreRouterConfigFunction = ( ) => StoreRouterConfig ;
230
-
231
213
enum RouterTrigger {
232
214
NONE = 1 ,
233
215
ROUTER = 2 ,
@@ -280,10 +262,7 @@ enum RouterTrigger {
280
262
providers : [
281
263
{
282
264
provide : _ROUTER_CONFIG ,
283
- useValue : {
284
- stateKey : DEFAULT_ROUTER_FEATURENAME ,
285
- serializer : DefaultRouterStateSerializer ,
286
- } ,
265
+ useValue : { } ,
287
266
} ,
288
267
{
289
268
provide : ROUTER_CONFIG ,
@@ -292,21 +271,23 @@ enum RouterTrigger {
292
271
} ,
293
272
{
294
273
provide : RouterStateSerializer ,
295
- deps : [ ROUTER_CONFIG ] ,
296
- useFactory : _createSerializer ,
274
+ useClass : DefaultRouterStateSerializer ,
297
275
} ,
298
276
] ,
299
277
} )
300
278
export class StoreRouterConnectingModule {
301
- static forRoot (
302
- config ?: StoreRouterConfig | StoreRouterConfigFunction
303
- ) : ModuleWithProviders ;
304
- static forRoot (
305
- config : StoreRouterConfig | StoreRouterConfigFunction = { }
306
- ) : ModuleWithProviders {
279
+ static forRoot ( config : StoreRouterConfig = { } ) : ModuleWithProviders {
307
280
return {
308
281
ngModule : StoreRouterConnectingModule ,
309
- providers : [ { provide : _ROUTER_CONFIG , useValue : config } ] ,
282
+ providers : [
283
+ { provide : _ROUTER_CONFIG , useValue : config } ,
284
+ {
285
+ provide : RouterStateSerializer ,
286
+ useClass : config . serializer
287
+ ? config . serializer
288
+ : DefaultRouterStateSerializer ,
289
+ } ,
290
+ ] ,
310
291
} ;
311
292
}
312
293
0 commit comments