-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inital State is empty on AOT #258
Comments
I've got the same with default factory (combineReducers) and a meta reducer inside the state tree. I always thought state was meant to be undefined when the init action is fired, so that the reducer would set its own initial value with Edit: the reducer (caught in a breakpoint on reduceState) doesn't actually do anything useful. It may as well be combineReducers({}). I'm guessing I still have the problem down in #116. My module is: const REDUCER_INJECTION_TOKEN = new InjectionToken<ActionReducerMap<AppState>>('...');
Object.assign(REDUCER_INJECTION_TOKEN, reducerMap);
...
StoreModule.forRoot(REDUCER_INJECTION_TOKEN),
...
{ provide: REDUCER_INJECTION_TOKEN, useValue: reducerMap }, and reducerMap is, basically export const reducerMap: ActionReducerMap<any> = {
undo: undoable(combineReducers( { /* ... */ } ),
other: reducers.here
} I don't suppose it would have anything to do with that |
You know what, why not just scrap the whole injector deal. Can't we have a v2-style API as well? We shouldn't have to leap through hoops to do what a one-liner provideStore did before. A reducer completely defines a store's initialisation. |
I just want to add: Changing the versions from ngrx store from 4.0.0 to 4.x.x hasn't solved the issue to me. This bug is crucial to me, I can not ship my application anymore. I'm happy to help with any information. Yet i don't know if I do something wrong or if there is a real bug in ngrx. It would be really great if someone would look into the issue. |
You can always downgrade to v2, which is pretty solid, or disable AOT in your production build if that doesn't explode your bundle size.
V4 is obviously causing a lot of AOT problems that should really have surfaced in a release candidate. I have the privilege of working on unreleased code, so workarounds and hacks are fine as long as they are eventually removed.
… On 15 Aug 2017, at 1:32 am, Renader ***@***.***> wrote:
I just want to add:
Changing the versions from ngrx store from 4.0.0 to 4.x.x hasn't solved the issue to me. This bug is crucial to me, I can not ship my application anymore.
I'm happy to help with any information. Yet i don't know if I do something wrong or if there is a real bug in ngrx. It would be really great if someone would look into the issue.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@Renader a small reproduction of the issue in a github repo would help. One thing that the new API has uncovered is the amount of people using factories which were being hidden behind using a function to return the reducers in V2. |
@brandonroberts I've attached a repro-repo. I'm currently traveling by plane so the code might be not the cleanest. The store contains of a "process" section which holds an invoice state. The invoice state is created by a factory. The example will not throw any errors since it doesn't contain any select functions. But as you can see in the dev tools on aot the state stays empty forever. Neither the initial state is created nor the action is properly processed. The example action is dispatched in app.component.ts Repro Steps Bug (aot):
-> Store is empty, Action not processed store at time of @ngrx/store/init:
Same is working in JIT:
-> Store is initialized, Action is processed. store at time of @ngrx/store/init:
Repository: |
I think this is connected with #189 |
@Renader thanks for the repo. This works in both cases with the latest release. I submitted a PR against your repo with the working changes Renader/ngrx-aot-258#1 Closing as resolved. |
I am still getting this issue in 5.2.0 |
@danielstern for me this issue was resolved with the fix of brandon. |
I'm still getting this issue (v 5.2) even if use simple example from documentation |
I also facing this issue. It is working properly in development mode, but when buidling release package with AOT mode, the intial state seems not get populated. I tried to set intial state when configure the store, but it leads the actions does not working (state cannot be changed). |
@marchino21 @stormit-vn could you open a new issue please, and if possible a reproduction. |
@tdeschryver Perhaps I'm misunderstanding protocol here, feel free to correct me if I'm wrong :) but since this is apparently exactly the same problem I'm having with v 6.0.1, I'm going to post here so that the team doesn't get duplicate bugs. I've reproduced a minimal example of the problem https://angular-fbmtou.stackblitz.io/ I hope it is clear :) |
@StephenPaul you can pass your initialState when you're calling
|
@tdeschryver, that fixes the problem. Much appreciated :) |
Spent the last two hour wondering what was wrong with my implementation. Turned out to be aot. @timdeschryver StackBlitz fixed it. How to use with aot should be add to the README. |
I'm submitting a...
What is the current behavior?
If I'm building my application with
--aot
my store object is{}
when the action@ngrx/store/init
is fired. (bad)When I build my application without
--aot
at the time of the init action the store object is already created in structure. (good)I'm using a factory and scoped actions but I'm not sure if that is related. I'm already working with a reducer token in order to make it work with --aot.
The bug affects all reducers, those created with a factory and reducers that are just a switch#case statement.
It might be related to #247 but I'm not using any meta reducers.
Expected behavior:
Same behavior in JIT/AOT
Version of affected browser(s),operating system(s), npm, node and ngrx:
ngx 4.0.0 , Angular 4.3.1, Angular CLI 1.3.0.RC5
Other information:
app.module.ts
index.ts
PaperworkReducerFactory
The text was updated successfully, but these errors were encountered: