Comments (7)
I tried changing it to this syntax, and the application can execute properly:
static list() {
return createSelector([CronState, SystemState], ({cronMap}: CronStateModel, {currentTime}: SystemStateModel) => {
console.log('list', cronMap, currentTime);
return [];
});
}
from store.
This is a circular reference issue: system.state.ts -> cron/index.ts -> cron.selector.ts -> system/index.ts -> system.state.ts
. Consider updating your file structure and remove barrel files where they're redundant.
from store.
Oh my goodness!
I used to encounter similar errors frequently before, and every time, I didn't know why they were happening or why they were resolved after fixing them.
Your answer helped me a lot.
from store.
@arturovt May I ask if you have any suggestions regarding the 'barrel file'? I'm not sure whether I should delete it completely, as it does seem quite useful.
from store.
Barrel files are used to simplify imports for external consumers, but they're always leading to circular references if not managed carefully. It's likely always a circular reference when you face an error stating 'cannot read properties of undefined, reading some class'. You either have to import the file directly from the chain (not cron
, but cron/actions
), because those files are neighbors, located in 2 close folders. Or you can do a dependency inversion, i.e., dispatch ResetConfig
outside the system state through actions$.pipe(ofActionSuccessfull(SystemAction.ResetConfig)).subscribe(() => store.dispatch(new ResetConfig()))
.
from store.
Following your advice, I changed the references to 'cron.action' in 'system.state' to 'directly file,' and the application is running fine.
However, when I tried a different way by modifying the import of 'system.state' in 'cron.selector,' it cause an error.
Why is that?
Uncaught ReferenceError: Cannot access 'SystemState' before initialization
from store.
I've deleted all index.ts
files, and now the world is filled with peace and love.
from store.
Related Issues (20)
- 🐞[BUG]: @Select decorator doesn't trigger value HOT 1
- 🐞[BUG]: it seems that Ngxs is not compatible with Jest ESM HOT 4
- 🐞[BUG]: patch operator does not handle null existing values
- 🐞[BUG]: export 'StateContext' (imported as 'StateContext') was not found in '@ngxs/store' HOT 2
- 🚀[FEATURE]: How to Load New State at Runtime? HOT 1
- 🐞[BUG]: Could not use NgxsFormPlugin in subModule on Federation Architecture HOT 1
- 🚀[FEATURE]: Support Angular 17 HOT 9
- 🐞[BUG]: NgxsFormPlugin not work in Angular17 HOT 1
- 🐞[BUG]: ngxs-store.js: Invalid count value HOT 16
- 🐞[BUG]: ResetForm action side effect completes after the action
- 🚀[FEATURE]: Allow Actions with non-static type fields HOT 2
- NoInfer TS 5.4 HOT 2
- 🐞[BUG]: Cannot read properties of undefined (reading 'NGXS_META') HOT 2
- 📚[DOCS]: Setup on application root level HOT 2
- Typing inline generic operators seems much more annoying with 3.8 (coming from 3.6) HOT 3
- 📚[DOCS]: Documentation needs more complete examples HOT 1
- 🚀[FEATURE]: Support Angular 18 HOT 14
- 🐞[BUG]: List of breaking changes or how to update to ngxs 18 HOT 2
- 🐞[BUG]: Using InjectionToken breaks Dependency Injection in state classes HOT 1
- 🐞[BUG]: Dispatching an Action within an `effect` causes an error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from store.