@@ -175,7 +175,7 @@ export function routerReducer<
175175
176176export interface StoreRouterConfig {
177177 stateKey ?: string ;
178- serializer ?: new ( ) => RouterStateSerializer ;
178+ serializer ?: new ( ... args : any [ ] ) => RouterStateSerializer ;
179179 /**
180180 * By default, ROUTER_NAVIGATION is dispatched before guards and resolvers run.
181181 * Therefore, the action could run too soon, for example
@@ -200,34 +200,16 @@ export const ROUTER_CONFIG = new InjectionToken(
200200export const DEFAULT_ROUTER_FEATURENAME = 'router' ;
201201
202202export function _createRouterConfig (
203- config : StoreRouterConfig | StoreRouterConfigFunction
203+ config : StoreRouterConfig
204204) : StoreRouterConfig {
205- let _config : StoreRouterConfig ;
206-
207- if ( typeof config === 'function' ) {
208- _config = config ( ) ;
209- } else {
210- _config = config || { } ;
211- }
212-
213205 return {
214206 stateKey : DEFAULT_ROUTER_FEATURENAME ,
215207 serializer : DefaultRouterStateSerializer ,
216208 navigationActionTiming : NavigationActionTiming . PreActivation ,
217- ..._config ,
209+ ...config ,
218210 } ;
219211}
220212
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-
231213enum RouterTrigger {
232214 NONE = 1 ,
233215 ROUTER = 2 ,
@@ -280,10 +262,7 @@ enum RouterTrigger {
280262 providers : [
281263 {
282264 provide : _ROUTER_CONFIG ,
283- useValue : {
284- stateKey : DEFAULT_ROUTER_FEATURENAME ,
285- serializer : DefaultRouterStateSerializer ,
286- } ,
265+ useValue : { } ,
287266 } ,
288267 {
289268 provide : ROUTER_CONFIG ,
@@ -292,21 +271,23 @@ enum RouterTrigger {
292271 } ,
293272 {
294273 provide : RouterStateSerializer ,
295- deps : [ ROUTER_CONFIG ] ,
296- useFactory : _createSerializer ,
274+ useClass : DefaultRouterStateSerializer ,
297275 } ,
298276 ] ,
299277} )
300278export 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 {
307280 return {
308281 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+ ] ,
310291 } ;
311292 }
312293
0 commit comments