-
Notifications
You must be signed in to change notification settings - Fork 310
Using combineReducers fails with AoT compilation #190
Comments
try to use:
|
No dice |
@brandonroberts I was able to get it to work by changing the initial reducer to useFactory instead of useValue and passing in my rootReducer factory. mhamel06@fdbb79a This would be a breaking change for existing users but I think it is the simplest way to make ngrx/store work well with AoT compilation moving forward. My code now looks like this
|
@brandonroberts @mhamel06 thanks, works great. I was trying this out something like this earlier but didn't import directly into provideStore so it wasn't working. |
might have spoke too soon, although it compiles, I'm getting undefined errors when routing to routes that use the store |
I get undefined errors when I'm using the current @ngrx/store version but they go away for me when I change this line:
to
Without that change I get the following
|
@mhamel06 cool. Easy fix |
This worked for me with current @ngrx/store version: |
is there any reason why #190 (comment) is not merged into master? |
The fix isn't needed as you can provide a function that returns the reducer to be compatible with AoT mode. |
for example? :) but wouldn't it be nice to have a aot compatible lib out of the box? |
It is AoT compatible out of the box. If you don't use AoT you don't have to use a function to return the root reducer. There could be some documentation added for the AoT requirement though. |
From the example repo this worked for me:
|
ok, I've got it. |
Closing since it works as designed with a function for AoT |
It should be noted that you should not only use an untyped Failing with ng2-final AoT:
Working with ng2-final AoT:
|
so in efforts to test the new --hrm feature I am running .22 with the following latest config:
regards, Sean. |
for others struggling with AOT (especially because of using angular-cli) in combination with the comment of the current lazy loading reducers workaround from here: #197 (comment) this is the working solution:
|
I cannot make this work... fails with "Calling function 'createReducer', function calls are not supported. " file1 file2
The following works JIT and fails AoT
The following fails JIT and works AoT
The following works at JIT and AoT but doesn't work to solve for lazy loaded reducers #197 (comment)
|
What I wasn't able to gather immediately from this thread was that the factory method arguments need to be provided to the createReducer return value. I'm chiming in to hopefully help others.
more conversation here about lazy loading techniques: #197 |
When I follow the method outlined by @mhamel06 on Sept 14, I get
and my state isn't undefined, but it also fails AOT compilation. |
@alsoicode if you see my comment above that will make it work. |
@josh-sachs I was able to get it working thanks to your comment. I ended up going with:
as I needed to clear the store on logout. |
@josh-sachs Hello, I've successfully used your posted code and the error was gone, I cannot seem to figure out how the Initially i used Please provide some explanation or direct me to the right place to understand. |
@kesemdavid my post from march 18 is for the 2.x release branch. Can you confirm you aren't trying to follow the 4.x release typings? The process for providing store to the application has change significantly between the two versions. |
@josh-sachs How did it change exactly? Im using |
When running AoT compilation, if I use the
combineReducers
function,ngc
throws an error.Error encountered resolving symbol values statically. Calling function 'combineReducers', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol reducer
app.module.ts
reducer.ts
ngrx/store v 2.1.2
The text was updated successfully, but these errors were encountered: