Closed labs-scnm closed 6 years ago
@labs-scnm what version are you using?
I tested with 2.0.0-rc.10
and 2.0.0-rc.12
.
@labs-scnm could you try not in the constructor? (different lifecycle hook or in the template) and see what that result is?
I tested it before on ngOnInit()
, same result.
@labs-scnm what about spitting it out in the template? I am only asking because our integration app isn't having this problem
@labs-scnm can you provide a repo or stackblitz that reproduces the issue?
On the template is the same result, it's empty.
It seems, the store init will dispatch before restore the state.
Ok, I will try to provide an example.
Ok, I found the problem. The restore dosen't work with lazy loading!
Here are an working example: https://stackblitz.com/edit/ngxs-localstorage
@labs-scnm excellent thank you!
Welcome! Hope you find a solution. βΊοΈ
ha me too :)
@labs-scnm we just pushed an update to lazy loading and feature modules. could you give it a shot?
Sry, but still same result. Empty result after reload. π
I updated also the example app, so you can verify the result: https://stackblitz.com/edit/ngxs-localstorage
I tested some possible scenarios, it seams the lazy state is loading to early from the local storage, also if I'm not running the lazy module.
Some Details If I have an lazy module with own (lazy) state, normally the state will be loaded first with the module. I can see an empty state on the DevTools, before I load the lazy module. But if the state restored from the local storage, the state is still exist, also before the the lazy module loaded.
I update my example app, to run and test this scenario.
Hope this will help to find the issue! π
@labs-scnm thanks for the info (and patience) I still haven't figured this one out and im burned out for the weekend. Ill try to get back to it something this week. could also use some help if you have any ideas
I use the
NgxsLocalStoragePluginModule
. After reload the app, the state will load from local storage correctly (state show correctly on dev tools), but the subscribe give me an null value.Any idea what I'm doing wrong?