GithubHelp home page GithubHelp logo

Comments (7)

qq253498229 avatar qq253498229 commented on July 17, 2024

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.

arturovt avatar arturovt commented on July 17, 2024

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.

qq253498229 avatar qq253498229 commented on July 17, 2024

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.

qq253498229 avatar qq253498229 commented on July 17, 2024

@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.

arturovt avatar arturovt commented on July 17, 2024

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.

qq253498229 avatar qq253498229 commented on July 17, 2024

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.

qq253498229 avatar qq253498229 commented on July 17, 2024

I've deleted all index.ts files, and now the world is filled with peace and love.

from store.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.