Giter Club home page Giter Club logo

Comments (5)

xmlking avatar xmlking commented on August 18, 2024

@sunger thanks for informing. for now you can ignore this warning. I will see how I can avoid such circular dependency.

I may have to reference AuthState's selector as text. but it is not working at the moment.
@amcdnl is there a solution/workaround for this case?

    this.store.select(AuthState.authMode).subscribe(authMode => {
      console.log(`Auth Mode Changed: ${this.authMode} => ${authMode}`);
      this.authMode = authMode;
    });

may be like this:

     this.store.select('auth.authMode').subscribe(authMode => {
      console.log(`Auth Mode Changed: ${this.authMode} => ${authMode}`);
      this.authMode = authMode;
    });

from ngx-starter-kit.

eranshmil avatar eranshmil commented on August 18, 2024

You can try:
@Select(AuthState) authMode$: Observable<AuthMode>;

from ngx-starter-kit.

xmlking avatar xmlking commented on August 18, 2024

@eranshmil as long as you use/refer AuthState in AuthService you will get Circular dependency WARNING.
if you don't want to see warning, then you can try this.

  @Select('auth.authMode') authMode$: Observable<AuthMode>;

and 

    this.authMode$.subscribe(authMode => {
      console.log(`Auth Mode Changed: ${this.authMode} => ${authMode}`);
      this.authMode = authMode;
    });

with this approach, I see ngxs store fires change event twice. which I don't like :(

Console log:

Auth Mode Changed: undefined => undefined
Auth Mode Changed: undefined => ImplicitFLow

With static reference to AuthState ie. this.store.select(AuthState.authMode).subscribe(....) it only fire one time as I expected.

 Auth Mode Changed: undefined => ImplicitFLow

from ngx-starter-kit.

eranshmil avatar eranshmil commented on August 18, 2024

I'd guess that's because the auth service is being initialized before auth state.
I recommend you to move some of the logic from auth service into the state, for example:

    if (this.authMode === AuthMode.PasswordFlow) {
      // For Password Flow
      return this.ropcService.logOut();
    } else {
      // For ImplicitFlow
      this.oauthService.logOut();
    }

I don't see any reason for that to be in the service and not in an action.

from ngx-starter-kit.

xmlking avatar xmlking commented on August 18, 2024

fixed.

from ngx-starter-kit.

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.