Replacing 'routerReducer' with a configurable option#417
Replacing 'routerReducer' with a configurable option#417brandonroberts merged 17 commits intongrx:masterfrom
Conversation
Latest Version
|
Changes Unknown when pulling 4583010 on PhillipZada:master into ** on ngrx:master**. |
| @@ -1,3 +1,4 @@ | |||
| import { StoreRouterConfig } from '../src/router_store_module'; | |||
There was a problem hiding this comment.
This can be added to the imports below from ../src/index
| @@ -155,18 +165,31 @@ export function routerReducer<T = RouterStateSnapshot>( | |||
| ], | |||
| }) | |||
| export class StoreRouterConnectingModule { | |||
There was a problem hiding this comment.
This would be a breaking change for existing users unless you add default providers to to NgModule metadata
| static forRoot(config: StoreRouterConfig = {}): ModuleWithProviders { | ||
| return { | ||
| ngModule: StoreRouterConnectingModule, | ||
| providers: [{ provide: _ROUTER_CONFIG, useValue: config }], |
There was a problem hiding this comment.
This won't work in AoT because the actual value for useValue property won't get resolved. You'll need to have two tokens, one for internal use that you register using useValue and another you register with useFactory that uses the first token as a dependency. Then you'll inject the public token in the constructor.
| private dispatchTriggeredByRouter: boolean = false; // used only in dev mode in combination with routerReducer | ||
| private navigationTriggeredByDispatch: boolean = false; // used only in dev mode in combination with routerReducer | ||
|
|
||
| private stateKey: string = 'routerReducer'; |
There was a problem hiding this comment.
Initialize this value in the factory function used to register the token
|
Hey @brandonroberts just wanted to get your thoughts my my previous comments. |
|
Hey @phillipzada. If you're talking about jasmine-marbles, I just responded to your comments. |
|
@brandonroberts sorry mate, I was referring the comments to your comments to the code changes above. Hey Brandon, Would this work, you do you still prefer an internal and external token? |
|
@phillipzada changes look good for the most part. You can't use |
|
Thanks @brandonroberts, appreciate the assist, will make the changes this week. |
|
Hey @brandonroberts, Changes have been made. |
|
Changes Unknown when pulling cbbe801 on phillipzada:master into ** on ngrx:master**. |
|
Thanks @phillipzada. One small thing. Change |
|
The providers in the forRoot method should be in the NgModule metadata also to prevent a breaking change for existing users. |
|
@phillipzada Can you fix the merge conflicts and failing tests? I'm ready to land this one. |
|
@phillipzada can you remove the |
|
@phillipzada sorry, I wasn't clear. Can you remove the |
|
So make a copy of the current version and put it back in? |
See #410