GithubHelp home page GithubHelp logo

Comments (4)

fulls1z3 avatar fulls1z3 commented on July 20, 2024 1

@pjmagee I chosen one of my projects as a victim and upgraded the ngrx to v4.0. It took a few hours, but got it running somehow. I tried to get the state of an object which comes from ngx-config (language) and resulted OK.

Well, resulted OK is such a very generic expression - I'm aware of that.

Is it possible for you to post the repro steps (github, plunkr, etc) so that I can try to have a look. Well, it might be a commercial project, or could take much time to elaborate even a smaller version.

I'll try to integrate ngrx v4.x to ng-seed/universal on the upcoming weeks (might be even closer, but don't want to cite a very precise and optimistic time) and maybe it could give you some clue.

from ngx-config.

fulls1z3 avatar fulls1z3 commented on July 20, 2024 1

@pjmagee you can have a look at ng-seed/universal, commit 6a50aac which closes fulls1z3/universal#70.

from ngx-config.

fulls1z3 avatar fulls1z3 commented on July 20, 2024

@pjmagee I think I understood what you meant. It seems like @ngrx began to use APP_INITIALIZER to resolve the effects before the app gets bootstrapped - as @ngx-config does. However, there's no interface which allows to prioritize the execution of functions supplied by the APP_INITIALIZER.

I would recommend to change the order of imports (at the app.module.ts, in NgModule section for instance) and see those values are still undefined or not.

Also try to update this post after you make some tries, and meanwhile I'll see what can I do for this.

from ngx-config.

pjmagee avatar pjmagee commented on July 20, 2024

I always ensure the ConfigModule is defined first in the imports list. Then I define near the bottom my EffectsModule. It seems like I'm looking for something now called ngrxOnRunEffects ngrx/platform#174

Essentially my problem is, I have a UserEffects that has a Security Service which takes the ngx-config service. This Security service has end points required for the user to login (I use Identity Server 4) so I need external endpoints to manage authentication. So this configuration really does need to happen before ANY ngrx effects are triggered. Because my Security Service is injected into multiple Effects I have.

I'm not sure how this ngrxOnRunEffects solve my problem, because my Security service is already injected into the Effect at that point. I can try to defer calling the config service GetSettings function and see how it plays out.

No matter what I try, it just appears that ConfigService never has the keys/values set in time, even once the page has rendered. So yeah, not sure how I can do this.

class Effects {  
   constructor(securityService: SecurityService) { } 
} 

class SecurityService { 
  constructor(configService: ConfigService) { }
 
  // configService getSettings() undefined v4.0
  // configService getSettings() defined perfectly pre v4.0 using RunAfterBootstrap
} 

@NgModule({ imports [  
          ConfigModule.forRoot({   // produces my ConfigService from Http to be injected into any Service 
            provide: ConfigLoader,
            useFactory: (createConfigLoader),
            deps: [Http, [ORIGIN_URL]]
        }),
        ...,
        EffectsModule.forRoot(EFFECTS) // new ngrx v4.0 (config settings always undefined)
        // Effects.RunAfterBootstrap(Effects) // pre ngrx v4.0 (config settings worked fine)
     ]})
class AppModule {

}

from ngx-config.

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.